Error with calling script include in flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 01:12 AM
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 -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 01:22 AM
Hi
basically it looks good. Is the Flow in the Global scope or in a Custom Scope?
Do you have a more detailed log for us? In which line exactly was the error?
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 02:23 AM
The flow is in another scope .
The script include is set as accessible from all application scopes.
I tried using log statements inside my generateDataFields function.
try{
//some logic
gs.log("data dictionary set");
}
catch(e){
gs.log("error in setting data dictionary" + e.message);
}
Both the log statements are not getting printed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 01:33 AM
There's probably an error in "// some logic to populate data1 & data2" section so the function generateDataFields() is not returning anything because of the error. Since nothing is being returned, calling "['dataone']" is creating an error.
2 things to do.
1. add a try - catch clause in the script include.
var fields = {
'dataone': '',
'datatwo': ''
};
try {
//
} catch (e) {
gs.error(e.message);
}
return fields;
2. check if the returned value is valid before calling "['dataone']"
var obj=new global.testScriptInclude();
var data = obj.generateDataFields();
if (typeof data != 'undefined') {
return data['dataone'];
}
return;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 02:24 AM
I tried using log statements inside my generateDataFields function.
try{
//some logic
gs.log("data dictionary set");
}
catch(e){
gs.log("error in setting data dictionary" + e.message);
}
Both the log statements are not getting printed.