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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Can you share relevant scripts and screenshots?

Regards
Ankur

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

Olly IB
Tera Contributor

Of course, thanks for the prompt!

There are several scripts in the flow but this is the one where I have added the variable to get the date/time:

(function execute() {
    var gr = new GlideRecordSecure(vaVars.table_name);
    if (gr.get(vaVars.sys_id)) {
        var comment = vaInputs.additional_information.getValue().trim();
        var escaltedOn = gs.nowDateTime();
        var priority = vaInputs.priority.getValue();
        gr.comments = 'The user has indicated this as a ' + priority + ' and added the following information: ' + '\n' + '\n' + comment;
        gs.eventQueue("x_mlg_mclaren_itsm.VA.Ticket.Escalation", gr,'' ,'' );
        gr.update();
    }
})()

Below this is a Lookup block to get ticket info:

find_real_file.png

And then the Record Action block that assigns the True value to the Escalation true/false field on the incident record.

The section of the flow looks like this:

find_real_file.png

 

The overall flow is as follows:

 

find_real_file.png

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

Muralidharan BS
Mega Sage
Mega Sage

HI,

You can get this done via "record action" component. 

 

 

Script Variable: create a script variable and click the code section to return the datetime as you did. 

find_real_file.png

 

use record action to link the datetime field from inc to this script variable as below.

 

find_real_file.png

then you can see the record is updated once

find_real_file.png