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 variables from Input records in Flow Action Script Step?

Daemon5
Tera Expert

Hi!
I have not been able to solve this problem for a long time and would like to know if you can help me.

 

I made custom Action for the purpose of converting Record type Input to Array.Object Output.
I think I may have succeed to comma-separate the Input and process it so that it goes into an Array.Object type.

 

But I couldn't get the Record`s variable and the test says [undenied][undenied][undenied]...

 Input value "records" refers "Table contains list column", and "Table contains list column" have List variable "u_list_test_column".

And the "u_list_test_column" refers 3 Strings from Table "Table contains string colummn".


If you know of a script that can take variables from the records, I would be glad to know.
Thank you.

1 ACCEPTED SOLUTION

Daemon5
Tera Expert

I could convert List type to Object.Array by making new Action.

Here`s script. Eureka!

(function execute(inputs, outputs) {
  //Create an empty array
  var valueinfoArray = [];
  var i = 0;
  //Iterate through the list of User records
  while(inputs.records.next()) {
    //Create an empty object for each iteration
    var contactObject = {};
    //Query User records to assign object values
    contactObject.string1 = inputs.records.getValue('u_string1');
    contactObject.string2 = inputs.records.getValue('u_string2');
    contactObject.string3 = inputs.records.getValue('u_string3');
    //Add current object to array
    valueinfoArray[i] = contactObject;
    i += 1;
  }
  outputs.valueinfo = valueinfoArray;
})(inputs, outputs);

 

View solution in original post

5 REPLIES 5

Daemon5
Tera Expert

I could convert List type to Object.Array by making new Action.

Here`s script. Eureka!

(function execute(inputs, outputs) {
  //Create an empty array
  var valueinfoArray = [];
  var i = 0;
  //Iterate through the list of User records
  while(inputs.records.next()) {
    //Create an empty object for each iteration
    var contactObject = {};
    //Query User records to assign object values
    contactObject.string1 = inputs.records.getValue('u_string1');
    contactObject.string2 = inputs.records.getValue('u_string2');
    contactObject.string3 = inputs.records.getValue('u_string3');
    //Add current object to array
    valueinfoArray[i] = contactObject;
    i += 1;
  }
  outputs.valueinfo = valueinfoArray;
})(inputs, outputs);