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

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.

0 votes



4 answers

Permanent link
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.

0 votes


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

Thanks.

0 votes


Permanent link
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.

0 votes


Permanent link
I changed the setvalue and save methods to act on the working copy and it resolved the error.

thanks.

0 votes

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,941

Question asked: May 29 '12, 3:50 a.m.

Question was seen: 6,454 times

Last updated: May 29 '12, 3:50 a.m.

Confirmation Cancel Confirm