- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 07:17 PM
The task_sla table has both the fields that I need:
- a boolean field "has_breached" which gives me the confirmation if the ticket has breached SLA.
- a reference field "sla"(table: contract_sla) which gives me either an SLA, or an OLA, or an Underpinning Contract
The code below gives me both the has breached value and the SLA type when I run it in the Background Script.
var gr = new GlideRecord('task_sla');
gr.addQuery('task', sys_id);
gr.addQuery('has_breached', true);
gr.query();
while(gr.next()){
if (gr.sla.type == 'SLA'){
gs.addInfoMessage("the SLA type is: " + gr.sla.type)
}
}
However, when I run the same code in a Script Include or as a callback function in a client script the SLA type produces an "undefine" value
Script Include:
var GetSLATypeAJAX = Class.create();
GetSLATypeAJAX.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getSLAInfo : function(){
var sys_id = this.getParameter('sysparm_sys_id');
var gr = new GlideRecord('task_sla');
gr.addQuery('task', sys_id);
gr.addQuery('has_breached', true);
gr.query();
while(gr.next()){
if (gr.sla.type == 'SLA'){
return true;
}
}
},
type: 'GetSLATypeAJAX'
});
This is not working because gr.sla.type is "undefine"
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 10:38 PM
Inside while loop log the sys_id and sla.type. If logged, check what values are you receiving.
getSLAInfo : function(){
var sys_id = this.getParameter('sysparm_sys_id');
var gr = new GlideRecord('task_sla');
gr.addQuery('task', sys_id);
gr.addQuery('has_breached', true);
gr.query();
while(gr.next()){
gs.log('Sys id received '+sys_id);
gs.log('This is the type of sla '+gr.sla.type)
if (gr.sla.type == 'SLA'){
return true;
}
}
},
Regards
Air
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 10:38 PM
Inside while loop log the sys_id and sla.type. If logged, check what values are you receiving.
getSLAInfo : function(){
var sys_id = this.getParameter('sysparm_sys_id');
var gr = new GlideRecord('task_sla');
gr.addQuery('task', sys_id);
gr.addQuery('has_breached', true);
gr.query();
while(gr.next()){
gs.log('Sys id received '+sys_id);
gs.log('This is the type of sla '+gr.sla.type)
if (gr.sla.type == 'SLA'){
return true;
}
}
},
Regards
Air