It's all about the answers!

Ask a question

How to get the new state name in operation advisor on performing save operation?


Yazhini Churchill (2135) | asked Jan 18 '13, 5:00 a.m.
edited Jan 18 '13, 5:33 a.m.
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



permanent link
Ralph Schoon (63.1k33646) | 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.

You have to look it up in the workflow info. See http://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/ for details.

I am not sure if it would help to resolve the work item and look at the state that is available after the save. You could try that.

You would see the new state in an advisor or participant that is run as a result of the save you just did. You can pass information between the operational behaviors using save3. See http://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ for some hints no that.


Yazhini Churchill commented Jan 18 '13, 5:28 a.m.

consider if the old state is validation and new state will be acknowledged.
The point is even before the save operation is complete(say,interrupted by an error message on save), I am getting the new state name as acknowledged.


Ralph Schoon commented Jan 18 '13, 5:44 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.

If you are looking for the state before the save finishes you can use the old state which provides the value of the work item before the save is finally committed.


Ralph Schoon commented Jan 18 '13, 5:45 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Also be aware that the newState data will only be committed if all advisors and participants agree.


Yazhini Churchill commented Jan 18 '13, 6:03 a.m. | edited Jan 18 '13, 6:06 a.m.

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?


permanent link
Ralph Schoon (63.1k33646) | 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.

permanent link
sam detweiler (12.5k6195201) | answered Jan 18 '13, 7:55 a.m.
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


Register or 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.