unable to modify custom attributes and thereby save workitem
Hi All,
This is the brief of my code:
IWorkItemServer service = getService(IWorkItemServer.class);
IWorkItem a = service.findWorkItemById(145, IWorkItem.FULL_PROFILE, monitor);
for (IAttributeHandle ia:a.getCustomAttributes())
{
IAttribute attribute= iac.resolveAuditable(ia,IAttribute.FULL_PROFILE, monitor);
a.setValue(attribute, finalexp);
IStatus st1 = service.saveWorkItem2(a, null, null);
I am getting assertion failed error at the setvalue method of the attribute. I read that we need to get a working copy of the item. My plugin is a server-side plugin and i couldnt find any options to setvalue or save work item using a working copy. How can this be done?
Thanks.
This is the brief of my code:
IWorkItemServer service = getService(IWorkItemServer.class);
IWorkItem a = service.findWorkItemById(145, IWorkItem.FULL_PROFILE, monitor);
for (IAttributeHandle ia:a.getCustomAttributes())
{
IAttribute attribute= iac.resolveAuditable(ia,IAttribute.FULL_PROFILE, monitor);
a.setValue(attribute, finalexp);
IStatus st1 = service.saveWorkItem2(a, null, null);
I am getting assertion failed error at the setvalue method of the attribute. I read that we need to get a working copy of the item. My plugin is a server-side plugin and i couldnt find any options to setvalue or save work item using a working copy. How can this be done?
Thanks.
4 answers
Hi,
Yes. Its true that you have to use Working copy of WI before using the saveWorkItem2 method.
Your can add a line before for loop.
a = (IWorkItem) a.getWorkingCopy();
But the Assertion failed is nothing to do with this. May be you have not sync the fields which are newly created in the Project area.
Yes. Its true that you have to use Working copy of WI before using the saveWorkItem2 method.
Your can add a line before for loop.
a = (IWorkItem) a.getWorkingCopy();
But the Assertion failed is nothing to do with this. May be you have not sync the fields which are newly created in the Project area.
Hi All,
This is the brief of my code:
IWorkItemServer service = getService(IWorkItemServer.class);
IWorkItem a = service.findWorkItemById(145, IWorkItem.FULL_PROFILE, monitor);
for (IAttributeHandle ia:a.getCustomAttributes())
{
IAttribute attribute= iac.resolveAuditable(ia,IAttribute.FULL_PROFILE, monitor);
a.setValue(attribute, finalexp);
IStatus st1 = service.saveWorkItem2(a, null, null);
I am getting assertion failed error at the setvalue method of the attribute. I read that we need to get a working copy of the item. My plugin is a server-side plugin and i couldnt find any options to setvalue or save work item using a working copy. How can this be done?
Thanks.
Yes. Format is correct.
Anyway try this also
IWorkItemReferences WIRef = service.resolveWorkItemReferences(a, null);
add this line before for loop and use this reference in the saveworkitem method
IStatus st1 = service.saveWorkItem2(a, WIRef , null);
But you should not get assertion failed error in the setvalue method. Try set value method in the WORKINGCOPY and tell me the result.
Anyway try this also
IWorkItemReferences WIRef = service.resolveWorkItemReferences(a, null);
add this line before for loop and use this reference in the saveworkitem method
IStatus st1 = service.saveWorkItem2(a, WIRef , null);
But you should not get assertion failed error in the setvalue method. Try set value method in the WORKINGCOPY and tell me the result.
I face this error at the setValue line and at the saveworkitem as well. Is the format of those lines correct?
Thanks.