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.

How to get all catalog variables from Script Step in a custom action in Action Designer in Flow Designer?

Anders Godstad
Tera Expert

Hi!

I'm currently trying to convert a Workflow to a Flow, where one of the steps of the workflow is to set RITM variables based on the existance of catalog item variables. 
Example: find_real_file.png

 

I wish to do this if-statement check in a custom action, so that it can be re-used for each catalog item. Therefore I do not wish to use the "Get catalog variables" action for each catalog item. 

What I'm wondering is: 

  • Is there a way for me to use something similar to Workflow's "current.variables" in a custom script step? 
  • Is there a way to retrieve all catalog item variables through a custom script step, and then apply the variable values to RITM fields based on the catalog variable existance?

 

Any help is appreciated 🙂

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

so you want to populate all variable details on RITM description.

you can pass the RITM record sys_id to that custom action

then query RITM and get all the variables in this syntax

var gr = new GlideRecord('sc_req_item'); 
if (gr.get(inputs.sys_id)) { 
    var variables = gr.variables.getElements(); 
    for (var i=0;i<variables.length;i++) { 
        var question = variables[i].getQuestion(); 
        gs.info(question.getLabel() + ":" + question.getDisplayValue()) ;
    } 
}		

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader