How to know user having only snc_internal role or many by using script

Nani18
Tera Contributor

Hello Experts,

 

I want to send an email notification based on user last login time.

To all users I can use below script

var gr = new GlideRecord("sys_user");

 

gr.addEncodedQuery('last_loginRELATIVEGT@dayofweek@ago@77^last_loginRELATIVELT@dayofweek@ago@75^active=true');


gr.query();

while (gr.next()) {

gs.eventQueue('User_inactive_76_days_reminder', gr, gr.email, gr.user_name);

}

 

Now My requirement is 

 

I want to skip users who is having only snc_internal role

example

ABC user is having ITIL and snc_internal (I want to send notification)

XYZ user is having snc_internal (I want to skip to send notification)

 

How can i add this condition in existing schedule job...?

 

Thanks in advance

 

Best regards

Nani

1 REPLY 1

Mayur2109
Kilo Sage
Kilo Sage

Hi @Nani18 

Refer below post, just replace sys_id of itil role with snc_internal.

https://www.servicenow.com/community/developer-forum/how-to-get-list-of-user-who-have-only-itil-role... 

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,
Mayur Shardul