Work Item References within server side Operation Advisor
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
Okay, I have found out how to get the Work Item References from within server side Operation Advisor:
ISaveParameter saveParameter = (ISaveParameter) data; 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. |
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. |
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); } } } |
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. |
Ralph Schoon (63.5k●3●36●46)
| answered May 02 '18, 4:55 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
|
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.