logo

NJP

Flow Designer Action Output Variables

Import · Feb 20, 2020 · article

Flow Designer is the future of workflows within ServiceNow. They're like business rules on steroids. Concepts such as custom Actions allow an incredible degree of flexibility in building components to solve specific issues within your ServiceNow instance. The documentation on how to do this, though, is lacking.

Recently, I had to build an action that dynamically determined the approver for a particular record based on a series of criteria that required a script. The challenge was how to get the output variable to work seamlessly with other OOB flow actions. The key to solving this was understanding how ServiceNow manages its complex variety of input/output variables.

The first step was to develop the script to determine who should be the approver, but once that was done, all that was needed was to set the output variable to be that specific gliderecord.

  var getApprover = new GlideRecord('sys_user')
  if(getApprover.get(outputs.approver_sys_id)){
    outputs.approver = getApprover;
  }

Then when defining the output variables in the Flow Designer interface, the critical step was to set the variable type to reference.table_name

image

Then out-of-the-box Ask For Approval accepted the custom action output variable.

image

Have fun

View original source

https://www.servicenow.com/community/now-platform-articles/flow-designer-action-output-variables/ta-p/2326528