We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

gs.isMemberof() from User of dotwalking field

Meloper
Kilo Sage

hi,

i have to Check the Groups of an User.

I get the Userinformations from a Field through a GlideRecord

gr.board.owner.getValue()

No i have the SysId but how i can Check the Group or Roles?

 

 

find_real_file.png

1 ACCEPTED SOLUTION

Ajay_Chavan
Kilo Sage

hey hi Please try below:

function test(){var VTBOwner="9da66f651b3333009998da49cc4bcb63";//put VTBowner=grCard.board.owner.getVale();
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('user', VTBOwner);
gr.query();
while(gr.next()) {

	if(gr.group=='0a52d3dcd7011200f2d224837e6103f2')// sys id of group1
		{
			gs.log('yes');
		}
	else {
		gs.log('no');
	}
 
	
} }
	test();

i have tested it output SS:

find_real_file.png

 

tthanks!!

if this helps then please mark if correct and helpful

 

Regards,

ajay

Glad I could help! If this solved your issue, please mark it as ✅ Helpful and ✅ Accept as Solution so others can benefit too.*****Chavan A.P. | Technical Architect | Certified Professional*****

View solution in original post

8 REPLIES 8

Ajay_Chavan
Kilo Sage

hey hi Please try below:

function test(){var VTBOwner="9da66f651b3333009998da49cc4bcb63";//put VTBowner=grCard.board.owner.getVale();
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('user', VTBOwner);
gr.query();
while(gr.next()) {

	if(gr.group=='0a52d3dcd7011200f2d224837e6103f2')// sys id of group1
		{
			gs.log('yes');
		}
	else {
		gs.log('no');
	}
 
	
} }
	test();

i have tested it output SS:

find_real_file.png

 

tthanks!!

if this helps then please mark if correct and helpful

 

Regards,

ajay

Glad I could help! If this solved your issue, please mark it as ✅ Helpful and ✅ Accept as Solution so others can benefit too.*****Chavan A.P. | Technical Architect | Certified Professional*****

Yes, i think that the only way ist to use a GlideRecord on the Groupmember Table.

I cant find wa way to use the GlideUser Methods for another user as current. Thank you

i used:

var userObj = gs.getUser().getUserByID(userSysID);

userObj.hasRole('role');

 

https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=GUser-getUserByID_S

thanks for sharing this too 

Glad I could help! If this solved your issue, please mark it as ✅ Helpful and ✅ Accept as Solution so others can benefit too.*****Chavan A.P. | Technical Architect | Certified Professional*****