How to filter out two column values at a time?

Raju Koyagura
Tera Guru

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.

1 ACCEPTED SOLUTION

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


https://demo013.service-now.com/u_test_condition_list.do?sysparm_query=u_status%3DX%5EORu_sub_status...


filter condition.JPG


View solution in original post

22 REPLIES 22

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


https://demo013.service-now.com/u_test_condition_list.do?sysparm_query=u_status%3DX%5EORu_sub_status...


filter condition.JPG


Thanks a lot for your quick response, Harish.


Someone else managed to come up with the same solution whilst I was writing my response!