- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2021 12:31 AM
Hi Team
I have one of the incident status as "On Hold" in ServiceNow. I have an API script in Python which fetches all the incident from ServiceNow. How do I get the timestamp of when incident state is changed to "On Hold" like we have resolved_at.
Basically, I need a variable that holds On Hold timestamp for my script logic. Which table holds this value? to which table do I have to pass the incident sys_id and get that On Hold timestamp?
Please let me know ASAP if anyone knows how to get this done.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2021 02:06 AM
You can use before update BR on incident table to set that custom date/time field
BR: Before Update
Condition:
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.u_field = new GlideDateTime(); // set the now time in this
})(current, previous);
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2021 02:06 AM
You can use before update BR on incident table to set that custom date/time field
BR: Before Update
Condition:
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.u_field = new GlideDateTime(); // set the now time in this
})(current, previous);
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2021 02:23 AM
Thanks Ankur. Let me Try. Where does this value gets stored? is that u_field custom field where the value gets stored for each incidents? is it in incident table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2021 02:42 AM
Yes u_field is the name of the field which you create of type Date/Time
It will be stored only when incident state changes to On Hold for the 1st time
Again if incident moves to In Progress and if you don't want to set this field again when incident moves to On Hold then add this in BR condition
State [Changes to] On Hold
AND
Field [IS EMPTY]
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2021 03:47 AM
Hi,
You could also use the API for the OOB table as an alternative for creating custom field on your table.
Note: create custom field has cost implication as per your ServiceNow Subscription
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader