Get a custom attribute value from a server side extension
Hi I am trying to extend my RTC with an OperationAdvisor . My concern is to force user to fill a given custom attribute when the state is "Resolved" (close state) and the Resolution value is "Fixed Upstream" 1. is there a way to compare state and resolution to real string values ("Resolved" and "Fixed Upstream") and not to their identifier (state.s5 and resolution.r1) 2. how can I get a custom field value (check if not null) from server side. I saw fews samples but I did not understand how to access workitem.attribute method from server side. I appreciate a detailed example Thx Roger |
Accepted answer
You can do this without an extension.
Go into the Process Configuration for your project, and select Team Configuration -> Operation Behavior, and then scroll to the bottom of the list of operations to Work Items -> Save Work Item (server). For that particular operation, select the Required Properties precondition, and set the fields that you want to be mandatory for users to fill in when the state and resolution are set to particular values (in your case, Resolved and Fixed Upstream).
Roger Layani selected this answer as the correct answer
Comments
sam detweiler
commented Apr 22 '13, 12:24 p.m.
No fair reading the requirements AND jumping to the no development required solution!..
Ralph Schoon
commented Apr 22 '13, 12:26 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Sometimes reading helps...... Hehe good catch. |
3 other answers
there is no direct way to use the state or resolution labels. they are contained in a different table than the IDs..
to access the value of a custom attribute on the server (or anywhere), use its ID as a string "com.xx.foo.bar" (or whatever it is in the process XML. the third post here shows how to decode the states. here is code I used in one plugin to check for "Resolved" state <code> private static String ResolvedState = "resolved"; IAuditableCommon iac = ((ISaveParameter) data).getSaveOperationParameter().getAuditableCommon(); WorkflowManager wfm = new WorkflowManager(iac); // reference the right object type (cast) IWorkItem workItem = (IWorkItem) auditable; // get the workflow this workitem is in, so we can get the labels of the states IWorkflowInfo x =wfm.getWorkflowInfo(workItem, monitor); if(Debug) System.out.println("the workitem state is "+ workItem.getState2().getStringIdentifier()+ "=" +x.getStateName(workItem.getState2()) ); // if this workitem is going into resolved state (we accessed 'proposed new' state above if(x.getStateName(workItem.getState2()).equalsIgnoreCase(ResolvedState)) </code> |
Ralph Schoon (63.3k●3●36●46)
| answered Apr 22 '13, 10:54 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Complementing Sam's answer, you can find code to handle states here http://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/ and several other API examples on that blog.
|
Dan Ralph Sam Thank you for answers I thought custom attributes are not visisble from Required Properties pre-condition Never mind the provided server side examples will be very helpfull for next extensions to come
|
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.