Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Error with calling script include in flow designer

Smriti Rastogi
Kilo Guru

I have a script include with this syntax 

var testScriptInclude = Class.create();
testScriptInclude.prototype = {
            initialize: function(currentObj) {
            this.currentRecord=currentObj;
},

generateDataFields:function(){
var fields = {
'dataone':'',
'datatwo':''
}
// some logic to populate data1 & data2

return fields

I am calling this in inline script in flow designer - 

var obj=new global.testScriptInclude(fd_data.trigger.current);
var data = obj.generateDataFields();
return data['dataone'];
 
Error: undefined is not a function.,Detail: undefined is not a function.
 
Any clue what I am doing wrong.
 
Also the same works in background script.
11 REPLIES 11

I usually test my scripts with "Scripts - Background" using "gs.info()" or with Script Include because it's much easier to debug.

FYI, I've tested the script in question with Scripts - Background and it worked without problem. Try commenting out the "some logic" codes to see if it works. If there's an error, it may be with the input/output variable settings.

yes it works with background script but not in flow designer.

Smriti Rastogi
Kilo Guru

The script ran perfectly fine with a custom action.

Not sure what the issue was with inline email script.

Hi

nice to hear, that you could solve your problem by yourself!

Kind regards
Maik