- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 12:15 AM
Dear,
I've written a script include and I wanted to call a function from that creates a record in another application from ServiceNow.
I've configured the business rule as,
Can you please tell what is the mistake here.
Regards,
Prashanthi Sathri
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 06:09 AM
@PRASHANTHI SATH , You can execute the script include in the following manner,
If your script include looks like the one given below:
var TestDemoFunc = Class.create();
TestDemoFunc.prototype = {
initialize: function() {
},
returnSomething:function(sysId){
gs.info('Inside Script Include');
//process some logic using sysID
return 'Hello';
},
executeSomething:function(){
gs.info('Execute Something');
},
type: 'TestDemoFunc'
};
Then go the Business rule and click on Advanced tab, from there you can invoke the script include as shown below:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
//Exeute the script include and store the result
var storedValue = new global.TestDemoFunc().returnSomething(current.sys_id);
gs.info('Stored Value is:'+storedValue);
//Just execute the script include
new global.TestDemoFunc().executeSomething();
})(current, previous);
You can take the help of the current object and pass it to your function in the script include. Attaching the screenshots for your reference.
Kindly mark my response as helpful if it helped you and let me know if you have any questions further.
Thanks,
Mahesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 12:25 AM
Hi Prashanthi Sath,
Are you sure that the Script Include is written correctly? Could you share a screenshot of the Script Include as well? It might not be defined as a function correctly.
Best regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 12:26 AM
Hi Prashanthi Sath,
Are you sure that the Script Include is written correctly? Could you share a screenshot of the Script Include as well? It might not be defined as a function correctly.
Best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 12:42 AM
Hi @PRASHANTHI SATH,
could you please share the script include screenshot? And a bit more explain the requirement.
Thanks
Jitendra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 12:46 AM
are you sure line 5 is not breaking?
line 7 which calls the function is correct.
share the complete script include code and the config screenshot
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader