About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Welcome to the Jazz Community Forum
How do you get an IIteration object from an IIterationHandle with the Server API?

I've included a part of my code below. I'm trying to create a server extension that can subscribe users based on where a work item is in our plans/sprints so I access to the planned for value. Everything I've found talking about converting the IIterationHandle to an IIteration deals with the client API. How do you do this with the server API?
public void run(AdvisableOperation operation, IProcessConfigurationElement participantConfig,
IParticipantInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException
{
Object data = operation.getOperationData();
ISaveParameter saveParameter = null;
if(!(data instanceof ISaveParameter))
return;
saveParameter = (ISaveParameter) data;
IAuditable auditable = saveParameter.getNewState();
IWorkItem workitem = null;
if (auditable instanceof IWorkItem)
workitem = (IWorkItem) auditable;
if(workitem == null)
return;
workitem = (IWorkItem) workitem.getWorkingCopy();
IIterationHandle plannedForHandle = workitem.getTarget();
IIteration plannedFor = null;
if(plannedForHandle != null)
{
plannedFor = (IIteration)plannedForHandle.getFullState();
}
One answer

I found the solution for this issue.
I needed to use IRepositoryItemService.fetchItem to retrieve the IIteration object from the IIterationHandle.
Here's the snippets of code I added to my extension:
import com.ibm.team.repository.service.IRepositoryItemService;
private IRepositoryItemService itemService;
itemService = getService(IRepositoryItemService.class);
IIterationHandle plannedForHandle = workitem.getTarget();
IIteration plannedFor = (IIteration) itemService.fetchItem(plannedForHandle, null);