- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 01:44 PM
Hi Everyone,
I'm very new to VA and conversation flows so this probably sounds like a dumb question but I can't find out why my script action keeps throwing an error.
My original task was to call a custom script include that checks to see if a functionality pilot exists and then if the user is part of the pilot and returns either yes or no. The script include works perfectly well all over the other parts of the system so the code in it is fine. It is also available to all scopes but written in the global scope. (VA is in a scoped app).
I have tried all sorts but as soon as it gets to my script action step the error occurs.
So I created a new conversation flow in my PID with the code as just a single gs.log statement, thus eradicating any issues with any customisations my employers may have done on the system but when I test it throws an error.
I must be missing a fundamental step as there is no complex code in a log statement. What am i missing? take a look:
very simple flow:
code in script action:
test:
Log and the error message
the error seems to be this: 21:38:19.346: java.lang.RuntimeException: Script evaluation error at [topic__PRVW__79f272b287790110312c54f7940c2891_task_primary_field___silent_ScriptedAction_fe4e871a62cb45419fb6263ca20d3dd1_prompt_msg]: Error occurred when processing message com.glide.cs.qlue.module.runtime.expression.JSExpressionEvaluator.evaluate(JSExpressionEvaluator.java:58) com.glide.cs.qlue.module.taco.QuestionAnswerInteraction.getLabel(QuestionAnswerInteraction.java:1067)
It is probably something I have overlooked but I can't find a solution anywhere.
regards,
Michael.
Solved! Go to Solution.
- Labels:
-
Virtual Agent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 12:44 PM
Thanks Allen and Murali for your responses i finally managed to figure it out.
The key was when i discovered that gs.log() doesn't work in scoped apps! that was what was crashing the node and not letting me continue. Allen was spot on. Just logging with gs.info() did the trick. i was able to log out all my statements to see where the code was falling down.
here are a few things i have learned that may be helpful for other newbies in future (this is on a Rome instance it may change):
- gs.log() will break your code as it is only available in global scope see Logging for Scoped Applications — ServiceNow Elite
- Any syntax errors or misspelling of table names / dot walking reference will stop your code running.
- When calling a client script the syntax is: var myvar = new scriptIncludeName().functionInCS('prams'); not a split version where you instantiate the Script Include and then call the function - this breaks your code.
- Contrary to the advice on the Test Virtual Agent guidance Test Virtual Agent topics | ServiceNow Docs only gs.info() and gs.warn() logging works and they log to syslog table and not the log in the chatbot test window.
- gs.print() has the same effect as gs.log() and breaks your code.
- You don't have to return anything from the function for it to move on. but follow the suggested syntax that is commented out when coding branching conditions.
- The script action node will run code up to the line that breaks the flow so gs.info() generously to find the exact spot that is causing you problems.
If i had know these simple things it would have saved hours of frustrated googling.
Take her easy,
Murph.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 02:23 AM
can you click the "always" and choose scripts and in return send true inside function.
return true;
can you try this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 12:44 PM
Thanks Allen and Murali for your responses i finally managed to figure it out.
The key was when i discovered that gs.log() doesn't work in scoped apps! that was what was crashing the node and not letting me continue. Allen was spot on. Just logging with gs.info() did the trick. i was able to log out all my statements to see where the code was falling down.
here are a few things i have learned that may be helpful for other newbies in future (this is on a Rome instance it may change):
- gs.log() will break your code as it is only available in global scope see Logging for Scoped Applications — ServiceNow Elite
- Any syntax errors or misspelling of table names / dot walking reference will stop your code running.
- When calling a client script the syntax is: var myvar = new scriptIncludeName().functionInCS('prams'); not a split version where you instantiate the Script Include and then call the function - this breaks your code.
- Contrary to the advice on the Test Virtual Agent guidance Test Virtual Agent topics | ServiceNow Docs only gs.info() and gs.warn() logging works and they log to syslog table and not the log in the chatbot test window.
- gs.print() has the same effect as gs.log() and breaks your code.
- You don't have to return anything from the function for it to move on. but follow the suggested syntax that is commented out when coding branching conditions.
- The script action node will run code up to the line that breaks the flow so gs.info() generously to find the exact spot that is causing you problems.
If i had know these simple things it would have saved hours of frustrated googling.
Take her easy,
Murph.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2022 02:01 PM
Hi,
Great news. As I had mentioned, it would be an issue with your script and yes, best practice is to never use gs.log() because it's not compatible with scoped apps (so even if you're working in global, just get in the habit of using gs.info()) and that's also why I specifically mentioned gs.info(), haha, and was more so focused around your actual code, not the logging, to see if I could help further.
If my reply above helped guide you Correctly, please mark that reply as Correct. I feel I had covered that in my initial reply.
Anyways, take care!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!