- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 03:13 AM
Dear all,
Scenario-1:-If the incident is in the state "solution proposed" and there is no action from the caller then it will be closed automatically after 5-days. (using BR)
Scenario-2:-if the incident is in the state "On Hold" and On Hold, the reason is "Awaiting User info". so in this case, if the caller is not responded to the incident up to 10days this incident will automatically be closed. (using Workflow)
My requirement is, I need to get all the list of those incidents which were closed based on the above scenarios, then I make the custom check box "true" on these incidents.
Could anyone please suggest to me the logic or some approach to do this....!
Please help
Solved! Go to Solution.
- Labels:
-
Script Debugger
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2022 10:49 PM
Hi,
data for comments and work_notes is stored in sys_journal_field
You can check for your incident record if there is any record in sys_journal_field with that comments or work notes value
if yes then it means it was closed by that scenario and then update the checkbox
Something like this
Ensure you give correct work_notes and comments text to find those records
var gr = new GlideRecord("incident");
gr.get("incidentSysId");
var rec = new GlideRecord('sys_journal_field');
rec.addEncodedQuery("name=incident^element=work_notes^valueLIKEclosed by scenario 1^ORvalueLIKEclosed by scenario 2");
rec.addQuery("element_id", gr.getUniqueValue());
rec.query();
if(rec.next()){
// update your checkbox
gr.u_checkbox = true;
gr.update();
}
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
‎02-16-2022 03:19 AM
Hello,
You can try to query by the 'Closed By' field.
If it was automatically closed, it should be a service account, like the system admin.
BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 03:52 AM
Hi feasible it would be to update BR/Workflow (being used to auto-close these incidents) adding an extra step that sets custom check box to True?
Hope it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2022 09:30 PM
Hi
I need to update the checkbox "Test"(field) to be "true". only for the incidents which are old incidents and already closed(Due to auto-closing), we need to update those records by using a background script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2022 09:47 PM
Hi,
are you updating comments or work_notes when you update from both the scenario
that can help you determine.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader