Update incident with action item (script)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2022 03:08 PM
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,
- Labels:
-
Agent Mobile App

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2022 07:37 PM
would you mind sharing some screenshot of what you done so far ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2022 07:40 AM
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2022 11:14 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 06:37 AM
Hi
Can you please clarify where you have added this script to the mobile function?
Thanks for your assistance.
Cheers,
Ron