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

Chavan AP
Tera Guru

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

Chavan AP
[ Architect | Certified Professional]

Was this response helpful? If so, please mark it as Helpful and Accept as Solution to help others find answers.

View solution in original post

8 REPLIES 8

Chavan AP
Tera Guru

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

Chavan AP
[ Architect | Certified Professional]

Was this response helpful? If so, please mark it as Helpful and Accept as Solution to help others find answers.

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 

Chavan AP
[ Architect | Certified Professional]

Was this response helpful? If so, please mark it as Helpful and Accept as Solution to help others find answers.