Custom Action issue

AvinashDubey
Giga Contributor

I have created a flow and custom action 

When i am testing the custom action individually it is given correct result but when i am calling it in flow and passing the same value as input 

It is giving wrong output

Ss

AvinashDubey_0-1758097029001.png

(function execute(inputs, outputs) {
    var prop = gs.getProperty('sw.list.1') || '';
    var data = (inputs.inputSysID || '').trim();
     
        prop = prop.replace(/[\r\n]+/g, '');
    data = data.replace(/[\r\n]+/g, '');
    // Split into array and trim each value
    var list = prop.split(',').map(function(s) { return s.trim(); });

    // Check if data exists in the array
    outputs.outputdata = list.includes(data) ? 0 : 1;
})(inputs, outputs);



Flow designer 
AvinashDubey_1-1758097092178.pngAvinashDubey_2-1758097119802.png

 



 

1 ACCEPTED SOLUTION

@AvinashDubey 

you can achieve this using Flow variable and no need to use Custom Flow Action

You can use "Set Flow Variables" flow logic and use script to set it with true/false

Share the action input screenshot, output screenshots

Your script can be made easy, it's looking unnecessarily complex

-> simply get the value from property

-> use toString() and split and search the sysId

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@AvinashDubey 

share what that action is doing?

only 1 script step?

action is configured to Run as System or User who initiated the session?

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

Action is tasking the sysid of catalog item and checking if that sys id is present in property file 

If yes setting the ouput as 0 is not output=1

@AvinashDubey 

you can achieve this using Flow variable and no need to use Custom Flow Action

You can use "Set Flow Variables" flow logic and use script to set it with true/false

Share the action input screenshot, output screenshots

Your script can be made easy, it's looking unnecessarily complex

-> simply get the value from property

-> use toString() and split and search the sysId

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