How to get the new state name in operation advisor on performing save operation?
In RTC workitem we move from one state to another state by selecting the specific action on save operation.Suppose if i get an error message in between saying the mandatory attributes have to be filled,the save operation is not complete. Now at this scenario what will be the new state value? I am getting the new state name value as about to be new state value(which is not correct, because the save operation is not complete). Only when the save is complete i should get the value as new state name.
The following code is being used to get the new and old state name.
if (auditable instanceof IWorkItem) {
IWorkItem wi = (IWorkItem) auditable;
Identifier<IState> newStateId = wi.getState2();
Identifier<IState> oldStateId = null;
IWorkItem oldState = (IWorkItem) ((ISaveParameter) data).getOldState();
if (oldState != null) {// New work item check.
oldStateId = oldState.getState2();
}
if ((newStateId != null) && !(newStateId.equals(oldStateId))) {
IWorkItemServer workItemServer = getService(IWorkItemServer.class);
IWorkflowInfo workflowInfo = workItemServer.findWorkflowInfo(wi, monitor);
newStateID=workflowInfo.getStateName(newStateId);
if (oldState != null){
oldStateID=workflowInfo.getStateName(oldStateId);
}
The following code is being used to get the new and old state name.
if (auditable instanceof IWorkItem) {
IWorkItem wi = (IWorkItem) auditable;
Identifier<IState> newStateId = wi.getState2();
Identifier<IState> oldStateId = null;
IWorkItem oldState = (IWorkItem) ((ISaveParameter) data).getOldState();
if (oldState != null) {// New work item check.
oldStateId = oldState.getState2();
}
if ((newStateId != null) && !(newStateId.equals(oldStateId))) {
IWorkItemServer workItemServer = getService(IWorkItemServer.class);
IWorkflowInfo workflowInfo = workItemServer.findWorkflowInfo(wi, monitor);
newStateID=workflowInfo.getStateName(newStateId);
if (oldState != null){
oldStateID=workflowInfo.getStateName(oldStateId);
}
3 answers
I misunderstood the question. In the NewState you get the state the work item would have if the save succeeds. If it does not, the state will be the old state. Honestly, I don't see a conflict with that and have a hard time to understand what you are asking for.
Comments
I would add an event handler and not a participant, this is how the RTC e-mail notification is done. Unfortunately I don't know of a published example.
If I would use a participant I would only trigger on the state change like done here https://jazz.net/library/article/1000 and I would put the participant at the end of the participants list in the process configuration.
If I would use a participant I would only trigger on the state change like done here https://jazz.net/library/article/1000 and I would put the participant at the end of the participants list in the process configuration.