It's all about the answers!

Ask a question

unable to modify custom attributes and thereby save workitem


VK L (8177157159) | asked May 29 '12, 3:50 a.m.
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.

4 answers



permanent link
Muthukumar C (32712833) | answered May 29 '12, 4:04 a.m.
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.




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.

permanent link
VK L (8177157159) | answered May 29 '12, 4:14 a.m.
I face this error at the setValue line and at the saveworkitem as well. Is the format of those lines correct?

Thanks.

permanent link
Muthukumar C (32712833) | answered May 29 '12, 4:28 a.m.
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.


I face this error at the setValue line and at the saveworkitem as well. Is the format of those lines correct?

Thanks.

permanent link
VK L (8177157159) | answered May 29 '12, 5:20 a.m.
I changed the setvalue and save methods to act on the working copy and it resolved the error.

thanks.

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.