- 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-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-12-2014 01:35 PM
Thank you very much!. I'll try that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2014 03:44 PM
Instead of an ajax call, you can check whether a user has any open incidents using a display business rule. This way you will have better performance.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2014 04:04 PM
That's a very good idea indeed but only for the already opened incidents, because the "display business rule" will take the value when the form will be opened.
As I understood here, we want to help the resolvers / service desk when they are creating new incidents, that means the caller value is changing from a blank value to something.
In that case, only a ajax call could (at my knowledge) do the work
But you're right to make the remark, if someone has to make the same feature at the opening of the form, the "display business rule" will be a better idea.
Regards,