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 had this idea of using custom action as a last option.

But odd how the inline script did not work.

 

Radek
Tera Expert

Hi, had the same issue in Vancouver - undefined, new global.NameOfScriptInclude()

it turned out - if it's under if condition than it's undefined..

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0791144

 

Workaround: 

1. define flow variable in the body of the flow + use the script include (I haven't tested subflow which could be used as well)

2. use the defined flow variable in the action