- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2015 12:12 AM
Hi All,
I am looking for addQuery/addEncodedQuery..etc to write below scenario to filter out the two column values at a time.
I have a two choice fields 'State' and 'Substate' with some choice values. I want to get the records which are not in State=X with Substate=Y.
var gr = new GlideRecord('table_name');
gr.query();
while(gr.next())
{
if(!(gr.status==X && gr_sasset.substate=='Y'))
{
//Some logic goes here
}
}
Instead of writing a if condition in the while loop, is there any alternate way to filter the records using addQuery/addEncodedQuery...etc. and for the same scenario how can we set filters for list in the UI (instead of script)?. Please suggest me in this, thanks in advance.
Thanks & Regards,
Raju.
Solved! Go to Solution.
- Labels:
-
Integrations
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2015 02:03 AM
I have created table as per your requirement in demo please click below link to login
https://demo013.service-now.com/login.do
username and pwd : admin
After login click this below link

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2015 12:16 AM
var gr = new GlideRecord('table_name');
gr.addEncodedQuery('status!=X^substate!=Y');
gr.query();
while(gr.next())
{
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2015 12:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2015 12:28 AM
Hi Kalairasan,
I appreciate for you'r quick response.
gr.addEncodedQuery('status!=X^substate!=Y');
This will filter out all the records which are having status=X and
substate=Y. But in my case, I don't want to filter when status=X with
substate=A,B,C. Just I want to filter only the records which are having the
status=X with substate=Y.
I hope now you understand my requirement clearly.
On Fri, Jan 9, 2015 at 2:16 AM, Kalaiarasan P <

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2015 12:40 AM
'^' that is a 'and' condition .. So it should hold good for your requirement .. Did you check that?