We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Handling Array.String in Flow Designer

NicholasC137604
Tera Contributor

I am attempting to create an Action with a scripted Step that takes in a String input[ from a list collector], and return two string arrays [Array.String] as output. I have create a script to achieve this and set the output equal to what I want. However, whenever I run the action I finding that the Array.String outputs never populate. Does anyone know how to properly populate output variables of [Array.String]? in a script. here is the current logic that I am using.

 

(function execute(inputs, outputs) {
    var primedList = inputs.mylist.split(",");
    var list1 = [];
    var list2 = [];
    for (var x = 0; x < primedList.length; x++) {
        var serverCurr = new GlideRecord('cmdb_ci_server');
        if (serverCurr.get('sys_id', primedList[x].)) {
            var mfr = serverCurr.getValue('manufacturer');
            if (mfr == 'sys_id_1_here') {
                list1.push(serverCurr.getValue('name'));
            } else if (mfr == 'sys_id_2_here') {
                list2.push(serverCurr.getValue('name'));
            }
        }
    }
    // Assign completed arrays to outputs in a single set
    outputs.list_one = list1;
    outputs.list_two = list2;
})(inputs, outputs);

 

When it comes time to actually trigger the flow, the output always returns as 

{"list_one":{}}

and as

{"list_two":{}}

 

1 REPLY 1

J Siva
Kilo Patron

Hi @NicholasC137604 

There is a typo in your script. Please remove the dot (.) in the 7th line. The rest of the script looks good and is working as expected.
(function execute(inputs, outputs) {

    var primedList = inputs.mylist.split(",");
    var list1 = [];
    var list2 = [];
    for (var x = 0; x < primedList.length; x++) {
        var serverCurr = new GlideRecord('cmdb_ci_server');
        if (serverCurr.get('sys_id', primedList[x])) { // Removed the (.) DOT
            var mfr = serverCurr.getValue('manufacturer');
            if (mfr == 'b7e7d7d8c0a8016900a5d7f291acce5c') {
                list1.push(serverCurr.getValue('name'));
            } else if (mfr == '0e8b8e650a0a0b3b004f285ffbb1a4fc') {
                list2.push(serverCurr.getValue('name'));
            }
        }
    }
    // Assign completed arrays to outputs in a single set
    outputs.list_one = list1;
    outputs.list_two = list2;

})(inputs, outputs);

 

JSiva_0-1776146969286.png

 

Regards,
Siva