- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2018 04:34 PM
Hi guys,
I've tried to follow the guide at https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f96196e to create a client script which uses script include but the script is not accessing the script include (or i'm not reading the data correctly). I have used this process in other Client scripts in slightly different manners and they work fine so i'm not sure what's happening, if I can get another set of eyes that would be greatly appreciated.
The table inherits the incident table, and uses a matrix of category/subcategory to determine the priority/SLA duration.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('AL_SCRIPT');
ga.addParam('sysparm_name','getPriority');
ga.addParam('sysparm_category', g_form.getValue('category'));
ga.addParam('sysparm_subcategory', g_form.getValue('subcategory'));
ga.getXML(parseAjax);
}
function parseAjax(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.addInfoMessage('priority: ' + answer);
if(answer){
g_form.setValue('priority',answer);
}
}
script include below:
var AL_SCRIPT = Class.create();
AL_SCRIPT.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getPriority: function () {
gs.addInfoMessage("finding priority");
var category = this.getParameter('sysparm_category');
var subcategory = this.getParameter('sysparm_subcategory');
var gr = new GlideRecord('u_ncr_matrix');
gr.addQuery('u_category', category);
gr.addQuery('u_subcategory', category);
gr.query();
if(gr.next()){
return gr.u_priority;
} else return false;
},
type: 'AL_SCRIPT'
});
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2018 09:59 PM
Might be a silly question but have you checked that "Client callable" is ticked on your script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2018 10:04 PM
Try the following code in background and let me know the result,
var gr = new GlideRecord('u_ncr_matrix');
gr.addQuery('u_category', category);
gr.addQuery('u_subcategory', category);
gr.query();
if(gr.next())
{
gs.print(gr.u_priority);
}
else
gs.print( "false");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2018 10:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2018 10:26 PM
Hi Rahul,
The issue was with the client callable box not ticked, I've picked up on the category thing and corrected it in my code already though.
Thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2018 12:26 AM
Can you please mark my answer as helpfull if it had helped you by any means .....