Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Related artifact reference not showing (RTC Java API)

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.

0 votes


Accepted answer

Permanent link

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

0 votes

Comments

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.

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.

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 log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,940

Question asked: Jan 05 '18, 10:08 a.m.

Question was seen: 1,917 times

Last updated: Jan 08 '18, 9:07 a.m.

Confirmation Cancel Confirm