- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2019 07:09 AM
Hi,
The below script is not working properly. In my script i want to add query with "AND" condition to check multiple fields like
- When state is 6,7,8
- u_is_planned = Unplanned
- Service Offering = Offername
If all the conditions are satisfied only then i want to update the description field. I know there is a syntax error in the below query. What correction i would need to do ?
gr = new GlideRecord('incident');
gr.addQuery('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();
}
Solved! Go to Solution.
- 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 🙂

- 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 🙂