- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 07:42 AM
Hi
I'm writing a new application and i want to add a cutom script field to a table that a workflow will locate via a glideRecord.
The idea is the workflow will execute the script.
I'm just a little lost on how to tell ServiceNow to execute a script in a script field on a custom table.
I expected a command like "gr.u_script.run" but cant find any reference.
Any suggestions welcome
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 07:49 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 07:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 08:08 AM
Hi Chuck
Would the script i reference be able to use the "current." or do i need to pass it in as a variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 08:50 AM
I ended up passing the current value in this allowed me to grab the current.varibales as well.
for those interested
where gr. is the referenced GlideRecord.
var evaluator = new GlideScopedEvaluator();
evaluator.putVariable(current);
evaluator.evaluateScript(gr, 'u_run_script', null);
Thanks Chuck
Regards
Neil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2017 05:07 PM
I'm trying to use GlideScopedEvaluator for the first time, and there is a specific point I am looking for clarification on that the documentation doesn't talk about. I wondered if you might enlighten me.
When using this evaluator, how am I supposed to be returning the information from the evaluated script? I first tried just using return "XYZ";. When that didn't work, I tried setting my desired return result to var answer = "XYZ". I've also just tried putting something like gs.info("TEST"); in the script to see if that logs anything, but nothing seems to be working. I just keep getting undefined.
If I'm not making sense, here is what I am going for...
I have mail script that run and calls a particular script include function to get the details of what the mail script is going to print out with template.print(MY SCRIPT INCLUDE);
This part I have confirmed is fully working. it only started to break when I included the evaluator into the mix.
I have setup a custom table with just 2 custom fields; u_name, u_script.
The script include has logic that will get it to identify a particular record on this custom table, I then want to return the result of the script field on this custom table through the script include to be printed out with the mail script.
Let me know if you need me to expand further on my explanation.
Any feedback would be helpful. Thanks!