Enable VIP Flag to all users from an Azure group

Luis Lithgow
Tera Contributor

I want to be able to enable the VIP flag for all the users in a group , pulled from Azure AD. 

 

I created a business rule:

When To Run: 

When: After

Order: 200

Group is: "XYZ vip Group from Azure"

 

Action: 

Nothing

 

Advanced:

Script: 

(function executeRule(current, previous /*null when async*/) {
 
//Make user a VIP when added to the group.
var gr = new GlideRecord('sys_user');
gr.get('sys_id', current.user);
 
gr.vip = true;
gr.update();
 
 
})(current, previous);
 
 
I only see that a brand new user will get the vip flag enabled but not for users that were already in the ServiceNow instance. Anyone able to point to me where I went wrong? Thank you
1 REPLY 1

Tony Chatfield1
Kilo Patron

Hi, I don't' believe that you have made any coding errors and as you indicated it works for new group members, which is correct expected behavior as your BR will only run when a new member is added to the group IE a new record is inserted into sys_user_grmember table.
For existing group members, you will need to update the sys_user records manually or with a background or fix script. Alternatively, you could remove all group members, then add them again, but this is less desirable as you will lose audit data identifying when they were first added to the group and by who.