How can i get data out of a data pill post Yokohama

LonLandry1
Giga Guru

I have noticed an issue post Yokohama release.

Simple custom actions that I built no longer work in flows.

The actions work, all logs are as expected when testing the action, but always fails in flows because the data pill (output from the action) seems empty - log messages go empty or undefined.

I was able to create custom actions with custom scripts before the Yokohama release.

Inputs
ca_1.PNG

Script step
ca_2.PNG

(function execute(inputs, outputs) {
// Log the entire inputs object for debugging
gs.log("Inputs: " + JSON.stringify(inputs));

// Check if table and field inputs are provided
if (!inputs.table || !inputs.field) {
throw new Error('Table and field inputs are required.');
}

// Retrieve the table sys_id and field from inputs
var tableSysId = inputs.table;
var field = inputs.field;

// Retrieve the table name using the sys_id
var tableRecord = new GlideRecord('sys_db_object');
if (!tableRecord.get(tableSysId)) {
throw new Error('Invalid table sys_id: ' + tableSysId);
}
var tableName = tableRecord.name;

// Log the table name for debugging
gs.log('Table name: ' + tableName);

// Retrieve the sys_id(s) from the lookup records action
var sysIds = inputs.sys_ids;

// Log the sys_ids for debugging
gs.log('sys_ids: ' + JSON.stringify(sysIds));

// Check if sysIds is defined and not empty
if (!sysIds) {
throw new Error('sys_ids input is required.');
}

// Split the sys_ids by new line or comma
var sysIdsArray = sysIds.split(/[\n,]+/);

// Log the sysIdsArray for debugging
gs.log('sysIdsArray: ' + JSON.stringify(sysIdsArray));

// Initialize an array to store the field values
var fieldValues = [];

// Iterate through each sys_id and retrieve the corresponding field value
sysIdsArray.forEach(function(sysId) {
var record = new GlideRecord(tableName);
if (record.get(sysId.trim())) {
var fieldValue = record.getValue(field);
gs.log('Field value for sys_id ' + sysId + ': ' + fieldValue);
fieldValues.push(fieldValue);
} else {
gs.log('Record not found for sys_id: ' + sysId);
}
});

// Log the field values for debugging
gs.log('Field values: ' + JSON.stringify(fieldValues));

// Set the output as an array of strings
outputs.field_values = fieldValues;

// Log the output for debugging
gs.log('Output field_values: ' + JSON.stringify(outputs.field_values));
})(inputs, outputs);

 

ca_3.PNG

end of script step ----
ca_4.PNG
ca_5.PNG

ca_5.PNG

 

I have also tried using Output type of array.string & array.object...

 

I opened a HI case but ServiceNow will not address because custom code is involved.

I guess that means ServiceNow allows but does not support custom actions used in Flow Designer.

Pretty crappy on ServiceNow's part if you ask me - they system is too rigid and returns data not helpful to humans, sys_id s as opposed to something identifiable by a human. 

2 ACCEPTED SOLUTIONS

LonLandry1
Giga Guru

Flow designer post Yokohama displays empty data pills if the pill is the result of a custom action. The pills will work as expected when testing but will not work in a flow.

View solution in original post

I look forward to the upcoming ability to debug custom scripted actions.

View solution in original post

18 REPLIES 18

JenniferRah
Mega Sage

Did you try setting your output variable to the string version of fieldValues rather than the JSON? I think it might work if you change the line that says 

outputs.field_values = fieldValues;

to this:

outputs.field_values = JSON.stringify(fieldValues);

I tried

outputs.field_values = JSON.stringify(fieldValues);

(again) and result is []

The result is empty when run in flow. When same data is used when testing the action, all is well.

Do you have the latest plugins installed for Flow Designer?

I believe so. Flow Designer is at 27.3.1