Can I know the logic for getting incidents which is "In Progress" for last 10 days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 09:55 AM
Hi Team,
Can I know the logic for getting the incidents which is "In progress" for last 10 days.
I need the background script for this.
Can Someone help me to get it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 10:56 AM
Hi @Roshini - Correct, the Script takes in a few assumptions and doesn't quite meet your requirement exactly.
As per my question above - Do you have 'PA' platform analytics - reporting? Otherwise, we may need to review SLA's, Metrics or the Audit history - please confirm.
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 11:02 AM
PA is there, But for the ultimate solution of mine I don't think i can make use of PA.
As the requirement is to send mail to the assigned to's manger for incidents which is in "In Progress".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 11:20 AM
Hi @Robbie
Try this script:
var gr = new GlideRecord('incident');
gr.addQuery('state', '2');
gr.addEncodedQuery('sys_created_onRELATIVEGT@dayofweek@ago@10');
gr.query();
while (gr.next()) {
gs.print('Incident Number: ' + gr.number);
}
Thanks and Regards
Sai Venkatesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 10:21 AM - edited ‎07-11-2024 12:58 AM
Hi @Roshini,
Building on top of what has previously been provided, a note on best practices - never user the variable 'gr'.
See why in the link below.
Additionally, this script will return Incidents that are currently 'In Progress' and have not been updated in the last 10 days. (As in their state has not changed)
@Roshini- However, and key point - that doesn't mean the list returns what you need. What happens if the incident has been updated but the state has not changed.
Do you have 'PA' platform analytics - reporting? Otherwise, we may need to review SLA's, Metrics or the Audit history.
Background Script:
var grInc = new GlideRecord('incident');
grInc.addQuery('state', '2');
grInc.addEncodedQuery('sys_updated_onRELATIVEGT@dayofweek@ago@10');
grInc.query();
while (grInc.next()) {
gs.print('Incident Number: ' + grInc.number + ' | Updated On: ' + grInc.sys_updated_on);
}
gs.print('Total Number updated: ' + grInc.getRowCount());
Link: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0713029
Reason: "When using more than one GlideRecord in your script, you may also accidentally re-use the gr name. The best practice is to use your own unique variable names, relevant to the table you are using, and never use 'gr'. e.g. So, just don't do it, and you will reduce the chances of this happening."
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 10:38 AM - edited ‎07-10-2024 12:39 PM
This will be giving the incidents which is "In Progress" and not updated for last 10 days.
But my requirement is to get the list of incidents which may or may not be updated but the state is "In Progress" for last 10 days.
Thanks for the input