It's all about the answers!

Ask a question

Work Item References within server side Operation Advisor


Jamie Berry (14013079) | asked Oct 15 '10, 6:28 p.m.
Hello,

I am trying to write a server side operation advisor for Work Item save that needs to access the parent and child references of the saved work item. I have figured out how to access the references from a plain java application, but am having problems determining how to get a hold of the objects I need while running on the server as an operation advisor. My code will need to find the referenced Work Items and load them in memory to access their types and some field values. Can anyone point me to some example code that would help shed some light on this?

Thank you,

Jamie Berry.

5 answers



permanent link
Jamie Berry (14013079) | answered Oct 26 '10, 4:19 p.m.
Okay, I have found out how to get the Work Item References from within server side Operation Advisor:

ISaveParameter saveParameter = (ISaveParameter) data;

IWorkItemReferences references = saveParameter.getNewReferences();


Now I am having trouble fetching the items that are referenced in order to determine their work item type and their ID. I have some client side code that uses ProviderFactory objects, but I can't seem to get it to translate to server side code. I will keep looking, but if anyone has any pointers, I would greatly appreciate it.

permanent link
Jamie Berry (14013079) | answered Oct 27 '10, 11:12 a.m.
I found out how to fetch the items, thanks to some pointers I found in this post: http://jazz.net/forums/viewtopic.php?t=10966

I was missing the part of having to list the services required for the advisor in order to gain access to the IRepositoryItemService (which can be used to fetch an item).

Now I am having trouble fetching the items that are referenced in order to determine their work item type and their ID. I have some client side code that uses ProviderFactory objects, but I can't seem to get it to translate to server side code. I will keep looking, but if anyone has any pointers, I would greatly appreciate it.

permanent link
praveen patidar (8613044) | answered Feb 05 '13, 9:55 p.m.
Here is the code that will fetch all related work items.
For Parent Use the constant : WorkItemEndPoints.PARENT_WORK_ITEM
For Child Use the constant : WorkItemEndPoints.CHILD_WORK_ITEM
---------------------------------------------------------------------------------------------------------
List<IReference>   relatedRefs = ((ISaveParameter) data).getNewReferences()
                        .getReferences(WorkItemEndPoints.RELATED_WORK_ITEM);

for (IReference ref : relatedRefs) {
                if (ref.resolve() instanceof IWorkItemHandle) {
                    if (ref.isItemReference()) {
                        referencedItem = ((IItemReference) ref).getReferencedItem();
                        relatedworkItem = (IWorkItem) repositoryItemService
                                .fetchItem(referencedItem, null);
}
}
}

permanent link
Ryan McFadden (191212) | answered May 02 '18, 1:26 p.m.

This topic is exactly what I am trying to do.   The link to the forum is broken and the code shown here doesn't compile. 


Your answer


Register or to post your answer.