hvrdhn88
Giga Patron

gr = new GlideRecord('incident');
gr.addEncodedQuery('stateNOT IN6,7,8^u_is_planned=Unplanned^cmdb_ci.u_service_offering.u_offer_name=' + offername + '^ORDERBYsys_updated_on');
gr.query();
while (gr.next()) {
gr.description = gr.description + '.';
gr.update();
}

 

try now

Calvaresi E_
Giga Expert

For AND conditions, just write another line with addQuery method.
For OR conditions, you can concatenate gr.addQuery(xx).addOrCondition(yy).
Otherwise you can use addEncodedQuery to write every condition in a single line, like:
gr.addEncodedQuery('u_configuration_itemIN' + current.u_configuration_item.toString());

Let me know if it helps.

Nithish1
Tera Guru

Hello Manikandan,

Instead of addQuery you can do 'addEnCodedQuery' and copy the query from the list filter.

Regards,

Nithish

siva_
Giga Guru

Hello Manikandan, 

 

For writing AND queries , if you are using multiple sequential addQuery statements it will treat that as an AND condition. 

if for writing OR queries in Glide Record, we have use something like addOrCondition 

 

Whenever you are writing complex queries, it is recommended to go to the list layout of that particular table and then build the filter condition you want to apply and MAKE SURE to right click at the end of the filter and click "copy query" . Once done , your query will be copied into the clipboard and by using the addEncodedQuery() of the GlideRecord class you can paste the query condition copied into the function as parameter. That really helps 

 

Mark this response as correct/helpful if that really helps

 

 

Thanks,

Siva

Manikandan2
Kilo Expert

For some reason the addEncodedquery() did not work however splitting the queries and executing worked fine 🙂 

View solution in original post