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

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

0 votes


Accepted answer

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

1 vote

Comments

No fair reading the requirements AND jumping to the no development required solution!..

nice!

Sometimes reading helps...... Hehe good catch. 


3 other answers

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


0 votes


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

0 votes


Permanent link

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

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

Question asked: Apr 22 '13, 8:29 a.m.

Question was seen: 4,152 times

Last updated: Apr 23 '13, 2:15 a.m.

Confirmation Cancel Confirm