"Pause" state Question

Hello All,

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!
Responses (4)
  • Accepted Answer

    Tuesday, October 09 2018, 05:40 PM - #Permalink
    One 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).
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, October 09 2018, 05:50 PM - #Permalink
    Hi 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.

    dim pstate
    pstate = Shell.FromStateID
    Call Shell.Item.SetFieldValue("PRIOR_STATE", pstate)

    Option Explicit
    Dim nstate
    Call Shell.Item.GetFieldValue("PRIOR_STATE", nstate)
    Call Shell.Item.SetFieldValue("STATE", nstate)
    • Paul Thompson
      more than a month ago
      If you use a Decision instead of script when coming out of the "Paused" state you'll get state history. You also won't have to set OWNER and SECONDARYOWNER fields.
    • Lynn Mattie
      more than a month ago
      The transition should set the Owner or Secondary Owner fields for the new state, so you shouldn't need to add a Decision as Paul suggests.
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, October 10 2018, 07:32 AM - #Permalink
    Hi 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?
    • David Sheaffe
      more than a month ago
      We are currently running 11.4, but we implemented this some time ago pre-ModScript. I haven't looked at trying to convert it from AppScript to ModScript as yet.
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, October 11 2018, 06:07 PM - #Permalink
    ModScript should work as well. Also, if you are using scripting the Prior State field can be an Integer field (since you will be working with state id's).
    The reply is currently minimized Show
Your Reply

Recent Tweets