Update incident with action item (script)

maria03
Tera Contributor

I have a UI action to acknowledge when an incident has been assigned to me and I need to re-create that in the ServiceNow Agent mobile app.

All what I need is to set the date/time when I select the 'acknowledge' option. for my UI action I have: 'current.work_start=gs.nowDateTime();'

for the mobile app, I tried using type=update for the Action item but when setting the field I can only select an specific date/time. I tested it and it works but now what i actually need is to be able to set the right date/time field.

I'm guessing I need to use the type = script but I cannot find any examples on how to update a field using the script. Any help will be greatly appreciated.

thanks,

 

4 REPLIES 4

Ravi9
ServiceNow Employee
ServiceNow Employee

would you mind sharing some screenshot of what you done so far ? 

maria03
Tera Contributor

sure,

in 'My incident' screen I created a function called 'Acknowledge action', it shows only if the incident is assigned to me and the work start field is empty. (this part is working).

Then my Action item is called 'Acknowledge Incident'. If I set the type =update and set the workstart to any date, the process works but I do not want to have a predefined date, I want the date/time from when the user selects 'acknowledge' in the mobile app.

thanks,

 

 

 

 

maria03
Tera Contributor

I'm not sure if this is the best way to do it but it works using the type script:

(function WriteBackAction(input) {
var gr = new GlideRecord('incident');
gr.addQuery("sys_id", input.sys_id);
gr.query();
if (gr.next()) {
var gdt = new GlideDateTime();
gr.work_start = gdt.getDisplayValue();
gr.update();
}
})(input);

Hi @maria03 ,

Can you please clarify where you have added this script to the mobile function?

Thanks for your assistance.

Cheers,

Ron