Updating a date/time field from VA

Olly IB
Tera Contributor

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

1 ACCEPTED SOLUTION

Hi,

you can use Script variable which can hold value

Then use that as input

Virtual Agent scripts

Store the current date/time using this

new GlideDateTime()

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Thank you!

 

I have done the following:

 

New Script Variable

find_real_file.png

 

However, when testing the topic it immediately errors:

find_real_file.png

 

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?

Hi,

Did you try to use new GlideDateTime()

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

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();
})()

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