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

(Server Side RTC) How to fetch the Previous state and Current state of the Workitem Workflow ?

For Server Side I want to fetch the Previous Workitem Workflow  state and Current Workitem Workflow  state .

0 votes



2 answers

Permanent link
current state is easy.

what does previous mean?  is your code in an advisor or participant extension?
is so, then the info is passed in to the call to the extension.
the about to be state is
    IAuditable auditable = ((ISaveParameter) data).getNewState();
the current (or old) state is
    IAuditable auditable = ((ISaveParameter) data).getOldState();

after that the info is stored in the history.  

0 votes

Comments

a)State transition from "Inprogress" to "Closed" , In Progress is "Previous" state

  b) It is a Advsior extension


Permanent link
Ok, the OldState should say 'InProgress',
and NewState should say 'Closed'

my advisor checks for workitems transitioning to 'Resolved' state..
String ResolvedState="resolved";

        if (data instanceof ISaveParameter) {
           
            // get the affected objects planned new state (cause this is a SAVE operation)
            IAuditable auditable = ((ISaveParameter) data).getNewState();
           
            // if this is a workitem
            if (auditable instanceof IWorkItem)
            {
                // get the worker objects
                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))

0 votes

Comments

Thanks Sam.  But the above code will provide only the current state , not the Previous state right ?  Correct me if iam wromg

Below is my code is similar to yours -----

Identifier<IState> state = sourceworkItem.getState2();

IWorkflowInfo workflowInfo = workItemServer.findWorkflowInfo(sourceworkItem, monitor);

System.

out.println (" Work Item Name :" + workflowInfo.getStateName(state).toString());

correct, my code only looks at the new state, I don't care about old..

but YOU DO.. so you could change my code a little to ge the PRIOR (aka old) state too

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

Question asked: Oct 22 '12, 7:08 p.m.

Question was seen: 5,724 times

Last updated: Oct 24 '12, 7:03 a.m.

Confirmation Cancel Confirm