Call script include from module argument not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2019 06:53 AM
Hi
I am calling script include from module arguments. Problem is, if i return hardcoded sys_id it works fine but when i write logic in script include it does not work.
Even if single gs.info() is written for logs without any other statement, it does not log the message.
Below is the screenshots.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2019 06:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2019 07:19 AM
Hello Ronak,
1. IN line number 12. make use of toString(). like below:
x.push.(gr.location.sys_id.toString());
2.use gs.log instead gs.info as its working in scoped application
gs.info : Logs informational messages that describe the progress of the application. Setting the log level for an application to info generates info, warn, and error messages, but does not generate debug messages.
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2019 07:22 AM
Whenever you're looping and pushing data directly from a query, you need tostring() it.
array.push(gr.sys_id.toString); OR array.push(gr.getValue('sys_id').toString);
And see if that helps. Whatever is causing this problem I've seen it hundreds of times. If you're looping and you're using an object, if you don't string it you may end up with a list of the same thing (or worse- if you're doing an update on this field, you'll find yourself updating the same record numerous times). I always make sure to toString() or format the object so ServiceNow treats the data separately.
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2019 07:01 AM
Hi Ronak,
can you use classless script include for this
i.e call it like this
^locationINjavascript:getLocationDetails
script include do this
function getLocationDetails(){
// your code
}
also while pushing into the array use toString()
x.push(gr.location.sys_id.toString());
return x.join(',');
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader