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

How to get certain values in an Operation Advisor?

This is probably pretty elementary, but ...
I am coding up an Operation Advisor to throw an error if the user attempts to move a work item into "In Progress" state when one of my custom attributes contains a certain value.

I have done a sample OperationAdvisor, but I am having a few issues with this one.
1) How can I get the value of a custom attribute?  I can do this in plain java but for that, I use a workItemClient.findAttribute() method, but I'm not sure how to get a workItemClient from within an Operation Advisor.  Or perhaps there is an easier way since I have the IWorkItem itself.

2) In the sample, the saveParameter there is a getOldState() method and getNewState() method.  Can someone help with what those would return?  My sample does getNewState() which then is cast to an IWorkItem. Does this mean these would be the values *IF* the save completed?  I don't think so based on some other things that I have read since the save hasn't occurred yet.  Or are these the IWorkItems with the old attribute values and the new attribute values that were selected?

Thanks
Susan

0 votes

Comments

Yes oldstate and newstate are the complete workitem..

before and the target after the save. you cannot change newstate

workitem.getvalue('id')is how to extract data from a field. just like in the client code for custom attributes u use the complete id.

Thanks Sam.  I initially had wanted to try workitem.getValue('id') but I only see getValue(IAttribute attribute) as a valid API.

Susan



2 answers

Permanent link
yeh, sorry.. morning
IWorkItemCommon workItemCommon= getService(IWorkItemCommon.class);
IAttribute attribute= workItemCommon.findAttribute(workItem.getProjectArea(), 'id', monitor);

u need to list IWorkitemCommon as a dependency in your plugin.xml

1 vote


Permanent link
Sam, you were right-on:
IWorkItemCommon workItemCommon= getService(IWorkItemCommon.class);
IAttribute attribute= workItemCommon.findAttribute(workItem.getProjectArea(), 'id', monitor);

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

Question asked: Jan 20 '14, 1:45 a.m.

Question was seen: 4,040 times

Last updated: Jan 21 '14, 6:19 a.m.

Confirmation Cancel Confirm