- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2014 09:10 AM
I want to write a script to alert if caller has active incidents so the service desk agent can click on related incidents icon and see what's active for the same caller. What should I be using?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var callerName = g_form.getValue('caller');
var target = new GlideRecord("incident");
if (target.addQuery('caller', callerName) && target.addQuery('active', 'true'))
{
alert ("Caller has active Incidents, please check related incidents for current caller");
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2014 09:55 AM
Hi Jesus,
Are you sure you don't want to just use the "related incident" icon on the right of the caller field?
If not, I think you should make:
1) not an alert (too invasive frrom my point of view) but a message under the caller field using g_form.showFieldMsg('caller_id','the caller has ' + numberofactiveincident + ' incidents currently active','info');
2) an asynchronous Ajax script to retrieve the information on the server side and send back the number of active incidents of the caller.
You should start by the point 2 (the point 1 is just cosmetic) and I give you this wiki article http://wiki.servicenow.com/index.php?title=GlideAjax
You need to start with "2.1.1.1 Hello World: Returning a value from the server" and don't forget the client side AND server side scripts.
Then, for retrieving on the server side the amount of incidents for the caller, I'm giving you the link http://www.servicenowguru.com/scripting/gliderecord-query-cheat-sheet/ where you can find getRowCount BUT I'll encourage you to try GlideAggregate (I don't remember where I read that but I think GlideAggregate is a better option for performance perspective)
The last advice with GlideAjax is to start with the wiki example and then to do what you want to do on the server side and then (when the server is sending back the right value) to modify the client side.
Best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2014 12:16 AM
You are right David. I overlooked the fact that it needed to be done at creation of a new incident.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/