- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2019 07:16 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2019 07:18 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2019 07:20 AM
Hello Manikandan,
Instead of addQuery you can do 'addEnCodedQuery' and copy the query from the list filter.
Regards,
Nithish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2019 07:28 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2019 10:38 AM
For some reason the addEncodedquery() did not work however splitting the queries and executing worked fine 🙂