Highlighted
curtiplas Frequent Contributor.
Frequent Contributor.
4000 views

"Pause" state

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!
Tags (3)
0 Likes
7 Replies
Micro Focus Contributor
Micro Focus Contributor

Re: "Pause" state

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).
0 Likes
dsheaffe Outstanding Contributor.
Outstanding Contributor.

Re: "Pause" state

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)
curtiplas Frequent Contributor.
Frequent Contributor.

Re: "Pause" state

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?
0 Likes
lmattie Absent Member.
Absent Member.

Re: "Pause" state

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).
0 Likes
PM Thompson Outstanding Contributor.
Outstanding Contributor.

Re: "Pause" state

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.
0 Likes
dsheaffe Outstanding Contributor.
Outstanding Contributor.

Re: "Pause" state

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.
0 Likes
lmattie Absent Member.
Absent Member.

Re: "Pause" state

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.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.