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); } |
3 answers
Ralph Schoon (63.6k●3●36●46)
| answered Jan 18 '13, 5:17 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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
Ralph Schoon
commented Jan 18 '13, 5:13 a.m.
| edited Jan 18 '13, 5:18 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Some more information on states API.
Yazhini Churchill
commented Jan 18 '13, 5:28 a.m.
consider if the old state is validation and new state will be acknowledged.
I fail to see the problem. It is a good thing that you see the target state, because you can now detect that a state change is happening and where it is going. If you wanted, you could prevent that from happening. This is actually a key capability for a majority of advisors and participants.
Also be aware that the newState data will only be committed if all advisors and participants agree.
I am checking both old and new state to send the notifications,ie if the old state is validation and new state is acknowledged only then it has to send a mail to the required user.If an error message appear in between disturbing the save operation,the new state value is acknowledged and sends mail. And even after the successful save operation also the new state name is acknowledged,so the mail is being sent twice.I am trying to restrict the mail sending onlu once.What is the possible way to avoid repetition of sending mails?
|
Ralph Schoon (63.6k●3●36●46)
| answered Jan 18 '13, 7:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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. |
I would send the notifications in the Participant, NOT the Advisor. the advisor ADVISES whether the transaction SHOULD complete. the Participant, PARTICIPATES in the transaction..
you still get the two states in the participant. and can still see the transition you are looking for. |
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.