Script Action Output (Array.String) output unable to map

Sirri
Kilo Sage

Hi Team,

I'm facing an issue in building a custom Subflow:
Script Action: Anti Crime Analytics Platform Access AD group manager

The Action:

1)Reads a catalog variable (approval_entitlement) from RITM.
2)Queries to custom table:
3)Plain Text table (u_ad_groups) In Adgroups records needs to be checked with the name(u_name) values needs to be compare with from approval_entitlement
4)Retrives (u_manager)

Sirri_1-1792843396240.png

 

Sirri_0-1792843327699.png

Script As per the Below:
gs.info('START_ACAP_ADGROUP_MANAGER_ACTION');

var managerMap = {};
var managerArr = [];

gs.info('RequestedItem:' + inputs.requested_item);

var ritm = new GlideRecord('sc_req_item');

if (!ritm.get(inputs.requested_item)) {

gs.info('RITMNotFound');
outputs.approval_managers = [];
return;

}

gs.info('RITMFound:' + ritm.getUniqueValue());

var entitlementStr = ritm.variables.approval_entitlement + '';

gs.info('ApprovalEntitlement:' + entitlementStr);

if (!entitlementStr) {

gs.info('ApprovalEntitlementEmpty');
outputs.approval_managers = [];
return;

}

var entitlements = entitlementStr.split(',');

gs.info('EntitlementCount:' + entitlements.length);

for (var i = 0; i < entitlements.length; i++) {

var entitlement = entitlements[i].trim();

if (!entitlement)
continue;

gs.info('CheckingADGroup:' + entitlement);

var grp = new GlideRecord('u_ad_groups');

grp.addQuery('u_name', entitlement);
grp.query();

gs.info('ADGroupCount:' + grp.getRowCount());

while (grp.next()) {

gs.info('ADGroupSysId:' + grp.getUniqueValue());
gs.info('ADGroupName:' + grp.getValue('u_name'));

var manager = grp.getValue('u_manager');

gs.info('ManagerFound:' + manager);

if (manager && !managerMap[manager]) {

managerMap[manager] = true;
managerArr.push(manager);

gs.info('ManagerAdded:' + manager);

} else if (manager) {

gs.info('DuplicateManagerSkipped:' + manager);

} else {

gs.info('ManagerEmptyForGroup:' + grp.getValue('u_name'));
}
}
}

gs.info('BeforeOutputAssignment');
gs.info('ManagerCount:' + managerArr.length);
gs.info('Managers:' + managerArr.join(','));

outputs.approval_managers = managerArr;

gs.info('END_ACAP_ADGROUP_MANAGER_ACTION');

Output variable defined:

Sirri_2-1792843528520.png


When we are trying to map output hear the output variable is read only so Unable to map what was the reason why it's coming as readonly. Is something I'm missing or how.

 But logs are coming with data correct basis on this I need to perform some other action in another subflow. Please let me know what I'm missing here.
Thanks 

7 REPLIES 7

That doesn't make sense.  You need to map to Script Step output to the action output. 

Tejas Adhalrao
Mega Sage

Hi @Sirri ,,

 

From your screenshots, the approval_managers output is already configured as Array.String, so the data type looks correct.

In your script, you are assigning the array using:

outputs.approval_managers = managerArr;

This is correct for an Array.String output.

You don't need to map or edit this output directly in the Action Output configuration. Save and publish the Action, then open the Subflow and use the approval_managers output pill from this Action in the next step.

If you want to pass this output to another Subflow, map the output pill to the corresponding input of that Subflow.

If the output is still empty, test the Action and check the execution details to confirm that the Script step returns the manager sys_ids correctly.

 

If this helped, mark it helpful and accept the solution.

Regards, Tejas

Assigning the array values in the script step to outputs.... populates the output of the script.  If this value is not mapped to the action output the action will not return any values.  Action outputs are the only things available outside of the action - to be used in a flow or subflow.  Individual steps within the action, such as a script step, are not accessible unless mapped to an action output.