How to call a script include in the Relationship table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 01:15 AM
I have created a Script Include and want to call it in the below query, what is the best way to code this? I am creating a new relationship to display in a related list, similar to this: How to create Scripted Relationships or Defined Re... - ServiceNow Community
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 01:21 AM
@thrsdy1512 You just need to call the Script include as
new yourScriptIncludeName().some1Function();// function which is just doing something.
var result = new yourScriptIncludeName().some2Function(pass_some_value);//function that returns something
gs.info('The result is:'+result);
Mark my response as helpful if it resolved your doubt.
Thank you,
Mahesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 03:51 AM
do i ned to create a new function as part of this or should i use a function from my script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 04:16 AM
it's as per your wish. create a new function or use an existing one if no code change is required in that function.
Did you check my below response?
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 01:27 AM
syntax will be similar to how you call from any server side
var returnValue = new ScriptIncludeName().functionName()
In your case if you wish to show approval records for your CHG then no script include required, this will work
current.addQuery('sysapproval', parent.sys_id);
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