How to filter Actions based on logic in a State

Created by Joshua Miller, Modified on Mon, 24 Mar at 10:25 PM by Joshua Miller

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:

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); 

Instructions

  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.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article