Change incident State after user specified time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 09:09 PM
Hello,
Incident State is "Awaiting User Info". And there should be one field which should capture user specified time. (e,g. User gave 26 hours of time). Now after 26 hours the State should automatically change to "Active"
And this can be repetitive process untill incident is resolved.
Note: we are not using flow designer for the current project
Please someone share your expertise on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 09:29 PM
Hi anvitha ash,
Did you check the business rule or schedule job work on that to chat state AUI -> Active?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 10:34 PM
Hi @anvitha ash ,
You can achieve this using scheduled events and script action.
I just simulated your requirement,
1. Created a Date/Time field "Set to active after (u_set_to_active_after)" so that user can set when the incident should become active.
Note: If you want this to be a simple text field like "Number of hours", you need to change the script in business rule.
2. Created an event in event registry like the one below.
3. Create Script Action like the one below.
4. Create a business rule "After - Insert/Update" like the one below,
Note: if you are using number of hours change the script to the one like below.
var date_time = new GlideDateTime();
date_time.addSeconds( parseInt(current.u_set_to_active_after) * 60 * 60 );
gs.eventQueueScheduled("incident.event.awaiting_to_active", current, "", "", date_time);
That's it! Try this and let me know if you want something else.
Thanks,
Anvesh
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 11:50 AM
Hello @AnveshKumar M ,
Thanks for sharing your response
I am not able to decode the code which is highlighted. Could you please let me know what that line is doing exactly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 12:12 PM
Hi @anvitha ash ,
Let me break it down,
parseInt(current.u_set_to_active_after) : this converts the user inputted time value to integer.
date_time.addSeconds( parseInt(current.u_set_to_active_after) * 60 * 60 );
So, the above line converts user inputted time (hours) to seconds ( hours * 60 min * 60 sec) and that value is added to current current time (date_time - GlideDateTime object), and we use that future time (current time + user inputted hours) to schedule the event.
Thanks,
Anvesh
Anvesh