We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

GlideQuery() or condition

Hamsika
Tera Contributor

Hi, My requirement is to search current logged in user in two groups using GlideQuery() only,  For that I have tried like this.

var gr = new global.GlideQuery('sys_user_grmember')
.where('group','287ebd7da9fe198100f92cc8d1d2154e')
.orWhere('group','8a4dde73c6112278017a6a4baf547aa7')
.where('user',gs.getUserID())
.select()
.toArray(1);

gs.info(JSON.stringify(gr));

 

Please let me know if there is anything wrong.

thanks

4 REPLIES 4

Ankur Bawiskar
Tera Patron

Hi,

you can use this script

var gr = new GlideRecord('sys_user_grmember');
gr.addQuery("user", gs.getUserID());
gr.addQuery("group.sys_id", "IN", "287ebd7da9fe198100f92cc8d1d2154e,8a4dde73c6112278017a6a4baf547aa7");
gr.query();
var isMember = gr.hasNext();

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi,

 

I need that using GlideQuery() only. Please provide that answer using GlideQuery() only.

Thanks

Ankur Bawiskar
Tera Patron

Hi,

check below links for help

GLIDEQUERY PART 1

GlideQuery

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hamsika
Tera Contributor

based on that document only I written that code, but I am getting Error. Please correct that code.

Thanks