How to get a plan record for a team?
![](http://jazz.net/_images/myphoto/a61449052fb6093f45574763eb5be53c.jpg)
Hello all,
I am struggling to find how to fetch an IIterationPlanRecord. Searching the SDK, I can't find a route to a plan from a project area or team area, and IIterationPlanService & IIterationPlanClient don't seem to offer what I'm looking for - I know how to create a Plan, but finding an existing plan is proving tricky!
Use case: We have a governance process that uses work items for items such as design documents that need tracking and approval. A change board meets regularly and there is a 'next meeting' plan they use to know what to review - the plan's iteration is updated weekly. I am automating processing to update the work items in the plan, adding approvals and emailing an administrator with details gathered from the work items.
So, I know the project area, the plan name and the plan's owning team but I need to know the iteration so I can get to the work items either via building a query or perhaps using fetchPlannedWorkItems. Either way, I must find the IIterationPlanRecord.
Can anyone give me a steer?
Accepted answer
![](http://jazz.net/_images/myphoto/a61449052fb6093f45574763eb5be53c.jpg)
Hi Cliff,
This may provide some help? using the REST API.
Rest API - Try https://clm:9443/ccm/rpt/repository/workitem?fields=workitem/iteration/*
3 other answers
![](http://jazz.net/_images/myphoto/a61449052fb6093f45574763eb5be53c.jpg)
Hi Matt,
good to hear from you and I hope all is well. This question is about SDB of course!
I hadn't thought of REST as a route to the iteration, so I'll have a poke around the docs - I think https://jazz.net/wiki/bin/view/Main/ReportsRESTAPI#Reportable_REST_API is propably a good starting place. I'd prefer not to mix and match methods, but if it gets me to where I need to be then so be it.
Comments
![](http://jazz.net/_images/myphoto/110ee3f07b99ddc5a77ecadac1af8978.jpg)
or have a look at this.. not sure exactly what you are up 2
https://jazz.net/forum/questions/181251/creating-iterations-using-java-api
I'm good - when can I come back to help! LOL
![](http://jazz.net/_images/myphoto/a61449052fb6093f45574763eb5be53c.jpg)
Yes, looks like REST is the way to go. Here's how to get the full picture of a plan (mine is called "Next SDB". The double quotes got translated into %22) :
https://<ccmserver>:9443/ccm/rpt/repository/apt?fields=apt/iterationPlanRecord[name=%22Next%20SDB%22]//
And to get just the iteration ID:
https://<ccmserver>:9443/ccm/rpt/repository/apt?fields=apt/iterationPlanRecord[name=%22Next%20SDB%22]/iteration/id
Thanks Matt - I'll call you soon - and if there’s a way to get this via the normal Java API I'd still like to know.
![](http://jazz.net/_images/myphoto/a61449052fb6093f45574763eb5be53c.jpg)
With some more digging I eventually found a way to do this using Sam's code in this thread as a guide: https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes
This is my version, which gives me exactly what I want:
public static IIterationPlanRecord getIterationPlanRecord (ITeamRepository repo, String planName,
BufferedWriter bw, Boolean debug)
throws TeamRepositoryException, IOException {
if(debug){bw.write("getIterationPlanRecord Entry\nLooking for Plan \'"+planName+"\'\n");}
IIterationPlanClient planClient = (IIterationPlanClient) repo.getClientLibrary(IIterationPlanClient.class);
IAuditableClient auditableClient = (IAuditableClient) repo.getClientLibrary(IAuditableClient.class);
List<IIterationPlanRecordHandle> phandles = ((IterationPlanClient) planClient)
.fetchAllIterationPlans(ItemProfile.ITERATION_DEFAULT, null);
List<IAuditable> itall = auditableClient.fetchCurrentAuditables(
phandles,
ItemProfile.createFullProfile(IIterationPlanRecord.ITEM_TYPE),
null);
int i; for (i = itall.size() - 1; i >= 0; i--) { // Loop from last to first
IIterationPlanRecord ipr = (IIterationPlanRecord) itall.get(i);
String thisPlan = ipr.getName();
bw.write("Plan Name: "+thisPlan+"\n");
if (thisPlan.equalsIgnoreCase(planName)) {
if(debug){bw.write("getIterationPlanRecord Exit\n");}
return (ipr);
}
}
if(debug){bw.write("getIterationPlanRecord Exit\n");}
return (null);
}
Comments
Matt Muller
Jun 06 '17, 5:30 a.m.Morning Cliff, Sound like an interesting use case..
You looked at the REST API?