Flow action tests perfectly on it's own but data pill seems empty in flow. Any ideas?

LonLandry1
Giga Guru

I have a custom action for Flow designer that has a successful test as expected.

But when the action is added to a flow, the data pill seems to return as empty.

 

`Tested with simple scripts to ensure the output host_names populates as expected.
`Tested with the exact raw text from step to ensure sys_id s is read correctly.

The   gs.info("host names: " + outputs.host_names); creates a log message as expected when run as action
but when run in flow the  gs.info("host names: " + outputs.host_names); creates a log message with only host names:

 

(function execute(inputs, outputs) {
    var sysIdArray = inputs.sys_ids.split(/\r?\n/).map(function(id) {
        return id.trim();
    }).filter(function(id) {
        return id !== '';
    });

    var hostNames = [];
    var seen = {};

    var gr = new GlideRecord('u_testcmdb_host_import');
    gr.addQuery('sys_id', 'IN', sysIdArray.join(','));
    gr.query();

    while (gr.next()) {
        var hostName = gr.getValue('u_application_name');
        if (!seen[hostName]) {
            seen[hostName] = true;
            hostNames.push(hostName);
        }
    }

    outputs.host_names = hostNames.join(', ');
    gs.info("host names: " + outputs.host_names);
})(inputs, outputs);

The output is a string, I have tested with & without mandatory selected.
The output is mentioned below the script step & in the Output area.
 
Any ideas?
6 REPLIES 6

@LonLandry1 

you are having input of type string

why are you doing a split?

how are you passing the input to flow? As already mentioned some issue in passing the input to flow action

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @LonLandry1 , @Lon Landry4 ,

 

Have you looked at the execution record for a Flow containing this Action? The step sections are expandable there to see a little more information on each Flow step, including the inputs, outputs, and message.

 

Like Ankur, I would want to review the inputs to the Action from the Flow (not on the Action level, but on the Flow level). And with the execution record open, I'd ask these questions: Is a string containing new line separated values being passed into the action? Does the data need an additional transform (i.e. type issues like an array or object being passed instead of a string)? Are there sys_id values in the string being passed to the Action, or is the data null, or a different non-sys_id data element?