What function of GlideRecord should I use to do 'NQ'?

peterraeves
Mega Guru

I want to query the below filter, but do not know which function to use to add the 'NQ' (new query). Please do not respond with 'you can use a string to create the encoded query', because that would be very ugly code. If possible, I would like to use the native GlideRecord functions. If not possible, I will do multiple queries, but just wanted to see if the function exist, as I cannot really find it in the docs.

u_holiday_calendar_id=B1^u_internal_grouping_time=1^ORu_internal_grouping_time=2^NQu_holiday_calendar_id=BL^u_internal_grouping_time=2

My code now

var list = [
    ['B1', 1],
    ['BL', 2]
];

var gr = new GlideRecord('u_my_table');
for (var i = 0; i < list.length; i++) {
    var row = list[i];
    gr.addQuery('u_holiday_calendar', row[0]);
    gr.addQuery('u_internal_grouping_time', row[1]);
    //Do the NQ
}
1 REPLY 1

mukulgupta
ServiceNow Employee
ServiceNow Employee

Hi There!

 

Have you tried using the method: addEncodedQuery(String query)

https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/glideRecordScoped/concept/c_GlideRecordScopedAPI.html#ariaid-title3

Thus for the filter you shared above you can used the method as follows:

gr.addEncodedQuery("u_holiday_calendar_id=B1^u_internal_grouping_time=1^ORu_internal_grouping_time=2^NQu_holiday_calendar_id=BL^u_internal_grouping_time=2");


Please let us know if the shared info was helpful by marking the response as Helpful.

Feel free to reach out if you have any additional questions.

Best Regards,

Mukul Gupta @ ServiceNow