It's all about the answers!

Ask a question

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


ANIL ABRAHAM (2321924) | asked Oct 22 '12, 7:08 p.m.

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

2 answers



permanent link
sam detweiler (12.4k6179201) | answered Oct 23 '12, 12:24 a.m.
edited Oct 23 '12, 12:26 a.m.
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.  

Comments
ANIL ABRAHAM commented Oct 23 '12, 10:01 a.m.

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

  b) It is a Advsior extension


permanent link
sam detweiler (12.4k6179201) | answered Oct 23 '12, 1:16 p.m.
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))


Comments
ANIL ABRAHAM commented Oct 23 '12, 2:29 p.m.

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());


sam detweiler commented Oct 24 '12, 7:03 a.m.

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 to post your answer.