How can I create an "Alert" to pop-up stating that a caller has Active Incidents?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2010 03:41 PM
Hello all!
I am looking for a way to create an "Alert" to pop-up stating that a caller has Active Incidents? We have an issue where several incidents are being created for the same issue in our Helpdesk. I am looking for a script that will check to see if the current caller has active or unresolved incidents. Would I do this through a script or Business rule. I have checked the wiki and community sites, but have not found a clear answer.
Any help on this would be greatly appreciated! And yes I am a rookie!
Thanks,
Paul
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2010 05:37 AM
The easiest way to do this is to set up a client script that runs 'onChange' of the 'Caller' field. The script will need to query the server for incidents for the given caller. This isn't hard to do, but you need to be careful when making queries to the server from client scripts because they can cause performance issues if they are overused. See here for more details on client scripting best practices...
http://wiki.service-now.com/index.php?title=Client_Script_Best_Practice
This script should do what you want.
function onChange(control, oldValue, newValue, isLoading) {
//Hide any existing field messages
g_form.hideFieldMsg('caller_id');
if (newValue == '') {
return;
}
if (newValue != oldValue) {
//Query for incidents for this caller
var user = g_form.getValue('caller_id');
var rec = new GlideRecord('incident');
rec.addQuery('caller_id', user);
rec.addQuery('active', true);
rec.addQuery('sys_id', '!=', g_form.getUniqueValue());
rec.query();
if (rec.next()) {
//If we find any then alert the user with a field message
g_form.showFieldMsg('caller_id','Caller has other open incidents','info');
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2010 05:42 PM
Mark,
Works like a charm. I will be careful in the future. This one however, was a necessary evil!
Thank you for the quick reply!
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2011 10:36 AM
OK, so this is working for the most part. However, it is popping up if a caller has an incident in the state "Resolved" as well.
I believe incidents in the incident_state "Resolved" are still technically considered "Active" until they go into the "Closed" state based on our Business Rule.
How can I tweak this script to omit incidents in the "Resolved" state, and only show incidents we consider "Active"
Any help would be greatly appreciated!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2011 10:49 AM
You'll need to figure out what state field you're using on incidents (incident_state or state) and then figure out what state value the 'Resolved' choice maps to...typically a value of 6. If you are using the 'state' field and your 'Resolved' value is 6 then you could change this line...
rec.addQuery('active', true);
to this...
rec.addQuery('active', true);
rec.addQuery('state', '!=', 6);