It's all about the answers!

Ask a question

Related artifact reference not showing (RTC Java API)


Chelo Vicente (235) | asked Jan 05 '18, 10:08 a.m.
edited Jan 05 '18, 10:09 a.m.

Hi, I'm having an issue while trying to create a related artifact reference from a workitem to a specific URL through the RTC Java Api. Reference just won't appear.

This is the snippet of code that creates and (theoretically) adds the reference to the workitem:

IURIReference reference = IReferenceFactory.INSTANCE.createReferenceFromURI(uri, comment);

IWorkItemReferences references = null;
try {
     references = workItemService.resolveWorkItemReferences(workItem, null);
} catch (TeamRepositoryException e) {
      LOGGER.error("TeamRepositoryException", e);
}
      references.add(WorkItemEndPoints.RELATED_ARTIFACT, reference);
      return references;

That's executed on an Advisor, so it should be saved automatically when the execution finishes.

Any clue on this? I've been doing some research and haven't found anything much different. I don't know what else to do.

Thanks in advance.

Accepted answer


permanent link
Ralph Schoon (63.3k33646) | answered Jan 05 '18, 10:15 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jan 05 '18, 10:19 a.m.

First of all you must not modify the triggering element in an advisor as you break the interface. An advisor is solely for the purpose to advise and prevent a save to enforce rules if needed.

Also the assumption that, if you modify the object of the operation the advisor is called for, the change to that object would be automatically saved in that operation is likely wrong. For one thing the save is already in process, so the transaction is already set up and won't accept any additional changes.

Like in a follow up action/participant, that you should have used in the first place, you would have to save the work item in an additional save. See example code: https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ . You should create a follow up action as well.

Chelo Vicente selected this answer as the correct answer

Comments
Chelo Vicente commented Jan 05 '18, 2:13 p.m.

I have modified it to make a participant.

This is what I'm getting now:

java.lang.IllegalArgumentException: Link does not reference work item

And as it is supposed to point to any URL, I don't know what kind of work item references is the saveWorkItem3 method expecting.


Ralph Schoon commented Jan 06 '18, 6:43 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

This indicates that you don't use the API correctly. A reference has two ends. So as a hint, open the link I suggested and use the search window for that blog and type in Link API. READ the blogs you find and look at the examples.


Chelo Vicente commented Jan 08 '18, 9:07 a.m.

Finally found an useful example that led me to the solution. Accepted answer on this post put me on the right way (that was not trying to create a new reference, but a new link).

Thanks for your help.

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.