Handling Array.String in Flow Designer
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Saturday
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":{}}
Labels:
- Labels:
-
Workflow Data Fabric
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
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);
Regards,
Siva
