- 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 01:42 AM
How can we set that condition in addQuery or addEncodedQuery?. I don't want
to apply that condition in while loop (Please look into the initial post).
On Fri, Jan 9, 2015 at 3:37 AM, Harish Murikinati <
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2015 01:48 AM
(status == X OR Substatus == Y) AND ( (status == X AND Substatus != Y) OR (status != X AND Substatus == Y) )
This should work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2015 01:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2015 01:59 AM
Thank you, Harish, It is working as expected. I appreciated....:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2015 01:55 AM
Thank you, Harish for your responses.
To get the expected output, below script is working. But my question is,
how can we set that conditions in list view manually or using
addQuery/addEncodedQuery condtions instead of writing it in while loop?.
var gr = new GlideRecord('table_name');
gr.query();
while(gr.next())
{
if(!(gr.status==X && gr_sasset.substate=='Y'))
{
//Some logic goes here
}
}
Thanks & Regards,
Raju.
On Fri, Jan 9, 2015 at 3:48 AM, Harish Murikinati <