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
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
Comments
sam detweiler
Jan 20 '14, 5:49 a.m.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.
Susan Hanson
Jan 20 '14, 6:01 a.m.Thanks Sam. I initially had wanted to try workitem.getValue('id') but I only see getValue(IAttribute attribute) as a valid API.
Susan