It's all about the answers!

Ask a question

How to find deleted parent item in operation participant?

Ivor Mirošević (122) | asked Jan 27 '14, 10:01 a.m.
Since i'm new to RTC, I have one question and any help would be appreciated.
I've created IOperationParticipant that is updating some data in workitem.
I've need to find out what workitem was parent to saved workitem before save.

The code I have is:

Object data = operation.getOperationData();
if (!(data instanceof ISaveParameter))

//this returns reference to new parent if added
//this returns empty array
//this returns empty array

I've tried using something like:

IAuditable oldStateAuditable = saveParameter.getOldState();
IAuditableCommon common = (IAuditableCommon)getService(IAuditableCommon.class);
IWorkItem oldItem = (IWorkItem)common.resolveAuditable(oldStateAuditable, IWorkItem.FULL_PROFILE, monitor);
oldReferences = workItemServer.resolveWorkItemReferences(oldItem, monitor);
but without success(it is also returning empty strings).

Based on this link:

my  approach should work.

what am I missing?

2 answers

permanent link
Surender Biyyala (403748) | answered Nov 15 '14, 3:38 p.m.
 you can use the following to know the deleted parent.

List<IReference> references = saveParameter.getNewReferences().getDeletedReferences(WorkItemEndPoints.PARENT_WORK_ITEM);
 and then use the 

for (IReference reference : references)
            if (reference.isItemReference() && ((IItemReference)reference).getReferencedItem() instanceof IWorkItemHandle)
                return (IWorkItemHandle)((IItemReference)reference).getReferencedItem();

sam detweiler commented Nov 15 '14, 6:09 p.m.

great info.. thanks

permanent link
Eric Jodet (6.3k5111120) | answered Jan 29 '14, 10:04 a.m.
 Hello Ivor,
Ralph's article -
may contain what you're looking for.
Check the code for findParentHandle method

Hope it helps,

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.