How to create a new comment for a workitem programmatically
Hi,
Please let me know how to create a new workitem using java/server side plugin programmatically. Regards, Chandan |
Accepted answer
if you don't know how to create a plugin, then you should take the extensins workshop,
see https://jazz.net/library/article/1000 if you do, then the logic is pretty simple (see the javadoc, downloadable from the product download section) get the workitem, get the workitem working copy workingcopy.getComments().xxx where xxx is either addComment(IComment object) or // corrected newComment=createComment(.....) append(newComment); then save the workitem private static IWorkItemServer fWorkItemServer = null; fWorkItemServer = getService(IWorkItemServer.class); fWorkItemServer.saveWorkItem3(workingCopy, null, null, some_indicator_for_recursion); Chandan M B selected this answer as the correct answer
Comments Hi Sam,
Yes - and a follow up action is called a participant. An advisor or pre-condition must not modify the element it is triggered for.
Chandan M B
commented Jun 12 '15, 5:17 a.m.
Hello,
Chandan M B
commented Jun 12 '15, 5:18 a.m.
What is not working? What happens if you debug it with Jetty.
sam detweiler
commented Jun 12 '15, 5:33 a.m.
hm.. your code is nearly exact to one of my plugins that works fine.
Chandan M B
commented Jun 12 '15, 6:16 a.m.
After executing
sam detweiler
commented Jun 12 '15, 6:22 a.m.
have to use an answer as the text is too big
Chandan M B
commented Jun 12 '15, 7:48 a.m.
Thanks it worked fine Sam.... :)
Chandan M B
commented Jun 12 '15, 7:49 a.m.
IContributorHandle creatorHandle = newState.getOwner();
You might want to consider to make the user that performs the operation the creator of the comment
IContributorHandle loggedIn = this.getAuthenticatedContributor(); If you want a hyperlink created, use the html tag and use
showing 5 of 12
show 7 more comments
|
One other answer
saveworkitem (and saveworkitem2 and saveworkitem3)
will cause ANOTHER execution of ALL appropriate plugins. the value of the third parm (the set) can be used to tell if YOUR plugin caused the recursion I check this in the plugin mentioned above with this code if (data instanceof ISaveParameter) { saveParameter = (ISaveParameter) data; // check to see if we are being called again from our save // if not, process, otherwise skip the work if ( (saveParameter.getAdditionalSaveParameters() == null) || (!saveParameter.getAdditionalSaveParameters().contains(Recursion)) ) { // not a recursion } Comments My hint was:
sam detweiler
commented Jun 12 '15, 7:01 a.m.
Ralphs blog pointed out that I gave you wrong info..
|
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.