How to create a new comment for a workitem programmatically
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(.....)
then save the workitem
private static IWorkItemServer fWorkItemServer = null;
fWorkItemServer = getService(IWorkItemServer.class);
fWorkItemServer.saveWorkItem3(workingCopy, null, null, some_indicator_for_recursion);
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);
Comments
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
}
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
}