I'm working on creating a "pause" state for a leave of absence. This is a state that should be accessible from anywhere in the workflow so naturally the transition into that state will be off the "ANY" state in composer. However, when leaving this state the item should be returned to the original state it was in prior to entering the "pause" state.
I know I'll have to save the original state value to a field, but I'm at a loss on how to actually go about handling the return functionality. Any suggestions/thoughts/examples/etc would be greatly appreciated!
Accepted AnswerEmployeeGarry WomackOffline0One option may be to use the Pause feature in the tool. But it acts more like a lock to keep it in its current state preventing transitions that change the state (as I understand it). Otherwise, you can add field overrides on transitions into the new paused state on a LastState text field. The field can save the internal name of the from state of the transition. Then, you can add a Resume transition (Any to Any/Same) that uses an orchestration to set the State field based on the content of LastState. The result is that the state would be changed to the desired state (even though drawn in the workflow editor as not being a state change).
Accepted AnswerDavid SheaffeOffline1Hi Curtis,
We do this using AppScript - steps are as follows:
From the 'Any' state we have a transition that goes to a 'Pause' state. During this transition we have an Action that runs a 'Pre-transition' script to get the State field value from the where the issue is coming from and sets that as the value of the "PRIOR_STATE" text field.
We have a second 'update' transition (to take off Pause) from the 'Any' state. As part of this transition there is another AppScript that gets the value from the "PRIOR_STATE" field and sets that as the value of the "STATE" field.
As part of the above we have disabled the "Pause" transition on some states where it isn't valid - and obviously the 'Take off Pause' transition is only enabled when the item is 'Paused. I have added the 2 appscripts below. There may be more elegant ways of doing this and others may have other suggestions - but this is what we use.
pstate = Shell.FromStateID
Call Shell.Item.SetFieldValue("PRIOR_STATE", pstate)
Call Shell.Item.GetFieldValue("PRIOR_STATE", nstate)
Call Shell.Item.SetFieldValue("STATE", nstate)
Accepted AnswerCurtis LaPriseOffline0Hi David This is exactly what I was looking for. Although I hadn't thought about appscript given the recent moves towards modscript.
What version of SBM are you using these on?
Accepted AnswerEmployeeLynn MattieOffline