Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

petercawdron
Kilo Guru

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

find_real_file.png

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

find_real_file.png

Have fun

Comments
ClareM
Tera Expert

Hi Peter,

 

I'm trying to do something similar.

 

Could you tell me where the script goes - is it in the script step or on the Action Output? 

 

Thanks,

 

Clare

amol_joshi
Tera Contributor

This is seriously a terribly non-intuitive product. Same with UI Builder. They think they are making it easier but end up ruining it.

 

I have a string as an input variable, a script and an array.object as an output variable. Despite the input variable and script being accurate, I still do not get the output array object.

MadavapeddiK
Tera Contributor

Hi @amol_joshi ,

I am having the same issue where input as String and output String Array and not getting mapped to output variables. I did debug just above outputs.<output array> and could able to see the value.

Please share if you get any solution for this.

 

Thanks,

Kartheek

Version history
Last update:
‎02-19-2020 09:37 PM
Updated by: