- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2022 03:53 AM
Hi all
Am stuck on what I think should be an easy task but it's had me pulling my hair out so looking for some assistance.
I have been working on a VA topic that allows users to chase or escalate a ticket. Part of the requirements for this is to have custom fields on the incident form for Escalated (true/false) and Escalated On (date/time).
In my topic flow I have been able to use a Record Action block to get the Escalated field to show as true, but am struggling to do the same for the date/time field.
What I am struggling to do is to create a script variable that can be referenced in the Record Action block. I've tried to create a variable and set the value to be gs.nowDateTime() but this variable is not selectable in the Record Action block.
I'm fairly new to scripting for VA (and in general) so am hoping that someone can point me in the right direction.
Thanks
Solved! Go to Solution.
- Labels:
-
Virtual Agent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2022 05:56 AM
Hi,
you can use Script variable which can hold value
Then use that as input
Store the current date/time using this
new GlideDateTime()
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2022 07:49 AM
Thank you!
I have done the following:
New Script Variable
However, when testing the topic it immediately errors:
Deleting the new script variable stops the error and the conversation works as expected. I haven't got as far as utilising it in the Record Action.
Is there something I am missing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2022 09:14 AM
Hi,
Did you try to use new GlideDateTime()
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2022 10:05 AM
I have now I've figured out that it still needs the return text and it's working perfectly, thank you.
For reference, this is what the Script Variable includes:
(function execute() {
/* return 'a default value'; */
return new GlideDateTime();
})()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2022 07:30 AM
If you would like to know about virtual agent scripting, these are two best resources you can find.
https://community.servicenow.com/community?id=community_article&sys_id=a70b286cdb90e410f21f5583ca961967
https://docs.servicenow.com/bundle/rome-now-intelligence/page/administer/virtual-agent/concept/virtual-agent-scripts.html