Script to determine age of a ticket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2015 06:10 PM
Hi everyone. I am happy you. All are here and can hopefully assist me
i tried this through inactivity monitor but it doesn't work correctly. So I would like to use another method like scripyin and have the scripting trigger an email
The parameters are. Check ll incidents if the incident is 30 days or more and still open, trigger an email to go out to the assignee of ticket. This should be done for all open, ain progress, pending or assigen. Got all tickets that are found an email is sent to the assignee and manager
i I don't want to use inactivity monitor. I would like to use a script which fire off an email
does anyone already have something like this or able ti share how this Cavan be accomplished
THANK YOU,,,
- Labels:
-
Integrations
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2015 08:33 PM
Hello Terry,
Refer to this page to see how to create a Scheduled script. Creating a Scheduled Job - ServiceNow Wiki
Use this script as the condition to first check if there are any scripts that are older tan 30 days,
var ga = new GlideAggregate('incident');
ga.addAggregate('COUNT');
ga.addQuery('active', 'true');
ga.addQuery('sys_created_on', '<', gs.daysAgo(30));
ga.query();
ga.next();
ga.getAggregate('COUNT') !== '0';
Then use this as the script:
var gr = new GlideRecord('incident');
gr.addQuery('incident_state', '<', 6);
gr.addQuery('sys_created_on', '<', gs.daysAgo(30));
gr.query();
while(gr.next()){
gs.eventQueue("incident.unresolved", gr);
}
Then go to System Policy -> Events -> Registry and create the event "incident.unresolved", select incident as table
Then create an email notification that runs when the event incident.unresolved is triggered, select incident as table. On who will receive select the assigned to field of the incident.
I think this is all you need to do to fulfill your requirement
Good luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2015 01:53 PM
Edwin, thank you so much for responding to me. I greatly appreciate it. I am a little confused about the two scripts. I created the first one no problem. Do I modify the first one with the second one or do I add it to the bottom of the first one or do I create a completely new script. Sorry I am a little confused and need a little more direction. Thank you so much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2015 02:30 PM
Hello Terry,
On the Scheduled Job you must select the conditional check box. After you select the check box you are going to see a condition field (text area). there you will have to place the first script. The other script must be in "Run this script"
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2015 05:36 PM
Hi Edwin, thank you for the response. I still can't get it to run. Can you tell me when I create the event do I select Business Rule or Notification. I have been selecting notification. I checked the events log and the scheduled job has run, but it is not sending any emails. Im not sure what I am going wrong. THANK YOU