Can we call script include from SLA filter condition?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 02:42 AM
Hi
Can we call script include from a SLA start condition using below?
javascript:newGetInSys().getinc();
I user the above method to call the script include function but it is not triggering from the SLA start condition.
I have verified the script and it is working in background script.
Thanks,
Neethu
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 03:23 AM
Thanks harshvardhan.
Haven't tested it from my side; but if it is working then it should be fine.
Probably the thread is 2years old.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 03:58 AM
javascript: new GetInc().getsysID();
The script include is used to get the sys id of incident where previous assignment group is GroupName1 and current assignment group is GroupName2 or vice versa.This script is giving the sys id of incident when executing in backgroun script
Script Include:
var arr = [];
var ar = [];
var sys;
var gr = new GlideRecord('metric_instance');
gr.addEncodedQuery('definition=def_name^valueLIKEGroupName 1^ORvalueLIKEGroupName 2^end=NULL');
gr.query();
while(gr.next()){
//gs.log('Total Count: ' + gr.id );
sys= new GlideRecord('metric_instance');
sys.addEncodedQuery('definition=def_name');
sys.addQuery('id',gr.id);
sys.orderByDesc('start');
sys.setLimit(2);
sys.query();
arr.splice(0, 2);
while(sys.next()){
arr.push(sys.value.toString());
}
ar.splice(0, 1);
if((arr[0]=="GroupName 1" && arr[1]=="GroupName 2")||(arr[0]=="GroupName 1" && arr[1]=="GroupName 2"))
{
ar.push(sys.id.toString());
gs.log("*****************Success****************: " + ar);
}
}
}
}
return 'sys_idIN'+ar.join();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 04:20 AM
Hi Neethu,
if I am understanding it correct there is conflict. In the question description you have mentioned you are calling your script include like this
javascript:newGetInSys().getinc();
and in the last comment you are calling you script include like
javascript: new GetInc().getsysID();
Can you double check the name of your script include and function and validate that you are calling it correctly from SLA condition?
Please mark this accepted/helpful, if applicable.
Thanks & Regards,
Sharjeel
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2020 04:53 AM
Hi neethu,
conditions work this way:
- When you specify a condition in the SLA Definition, you use the filter builder to construct an encoded query.
- When the SLA Engine does it's condition checking, it does it by executing the encoded query for a single task record:
- i.e., WHERE <encoded query> AND sys_id returns a record, the condition is true; if nothing is returned, the query is false.
And the script processing you want as a filter condition (like for a reference qualifier) needs to be done as a pre-processing step, to generate the final encoded query.
You might want to try the following method to implement this:
a. Create a custom field to hold your script include return result: for example, u_my_condition true/false
b. Create a before-insert business rule to evaluate your script include function and store the result in your custom field.
c. Add your custom field to the desired SLA Condition: AND u_my_condition is true
Mark correct or helpful if this works.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2020 05:50 AM
This does not hold true anymore. The condition checker CAN call script includes, as specified above.