How to filter Actions based on logic in a State

While Actions can be filtered using permissions and Custom JavaScript in a form (by hiding/showing buttons), another technique that is useful is to use the Advanced tab of the State editor to provide JavaScript to apply logic to subset the Actions returned based on contents of the Workflow Item and current State. Generally, a superset of the actions are permitted in the Workflow editor, and then “weeded out” using calls to removeAction(…).

Code example:

1 2 3 4 5 6 7 8 9 10 11 12 13 filterActionList = function (workflowItem, actionList) { var request = JSON.parse(workflow item); var actions = JSON.parse(actionList); // Any field from the request can be referenced var requestType = request["extendedfieldRequestType"]; if (requestType === "PEC Reservation") { // Remove the Escalate option actions = removeAction(actions, "Escalate"); } return JSON.stringify(actions); }


  1. Edit the workflow State where the choice of actions is to be filtered,

  2. On the Advanced Tab, use code like the example above to remove any Actions that do not make sense given the context of the State and contents of the Request

  3. Return the remaining actions as a JSON string.


Make sure the list of Actions is returned as a JSON string as shown above.