Using GlideFilter.checkRecord

Vasanth Pandia1
Tera Contributor

Hi All,

For one of the requirement, we are using "GlideFilter.checkRecord(current,sla_record.start_condition)". this actually checks the current sc_task record and the start condition of the SLA record.

But in the start condition of the sla record, we also have few conditions referring to requested Item table which is parent of sc_task. In this case this is not working. even though we have those reference fields in sc_task record. can some please let me know how can we do this?

Regards,

Vasanth

13 REPLIES 13

andrew_venables
ServiceNow Employee
ServiceNow Employee

Can you share the start condition?


Vasanth Pandia1
Tera Contributor

Hi Andrew,



Thanks for replying!


Below is an example of the start condition.



Ex: The SLA is running on sc_task table and in start condition we have:


Active is true AND Assignment Group.Service Provider is "EXAMPLE" AND Request Item.Priority is "EXAMPLE"



This is how the start condition looks and in sc_task table we have a field "request item" as well which is a reference and it refers to the parent.


When I remove the condition Request Item.Priority is "EXAMPLE" from the SLA, the script returns correctly. when I include this it doesn't.



Regards,


Vasanth


The SN Nerd
Giga Sage
Giga Sage

Does your query contain multiple conditions?



You may need to add a third parameter



checkRecord(GlideRecord gr, String filter, Object matchAll)



Your code should then be




GlideFilter.checkRecord(current,sla_record.start_condition, true)



The method returns true when the record meets the filter condition. If the filter is composed of one or more "AND" conditions for example"active=true^number=abc^category=request"and the matchAll parameter is set to false, then if any of the conditions is true then true is returned. If the matchAll parameter is true, then all conditions in the filter must be true in order to return true.



Parameter(s):



NameTypeDescription
grGlideRecordThe GlideRecord to be evaluated.
filterStringAn encoded query string.
matchAllObject(Optional) If true and the encoded query string contains multiple conditions then all conditions must be true for the method to return true. If false and the encoded query string contains multiple conditions then only one condition needs to be true for the method to return true. If the encoded query string has only one condition, this parameter has no impact.


https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_ScopedGlideFilterCheckRecord_GlideR...



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Vasanth Pandia1
Tera Contributor

Hi Paul,



Thanks to you too.


Yes we have multiple conditions in the SLA, as I mentioned in my previous reply.


How do I include the 3rd parameter? Since this is throwing me errors:



GlideFilter.checkRecord(current,sla_record.start_condition, sla_record matchAll);



Please help me with this.



Regards,


Vasanth