Make user VIP when part of a group ?

Floridalife
Giga Expert

We want to manage VIP user using groups, how can i enable the VIP checkbox auto when the user is part of a group ?

1 ACCEPTED SOLUTION

The problem with that is you are needing the business rule to run off the sys_user_grmember table and setting a value in the sys_user table.


Plus, we've determined that it runs when you manually add/remove someone from the group, so the business rule seems to work.



Here is what i would do.


Create a new community post with the question of why is my business rule not running on the LDAP import explaining that it works when you manually add someone to the group, but when the transform map does it, the business rule does not run even when 'run business rules' is checked.


This might find someone who has an answer to respond since this issue is not obvious from the current post question...


View solution in original post

38 REPLIES 38

You must be in Fuji, business rule scripts have changed with each release a little.   Follow Pradeeps instructions but only copy lines 4-11 above and paste that into the function in your business rule in the advanced tab.   This code should go between the curly {} brackets.


Thanks, the code got saved, i added the user to the group for the condition to apply but VIP still didnt get checked, how does it look so far?



The user i tested on is part of the group Authorized_to_skip_approval



function onAfter(current, previous) {


    //This function will be automatically called when this rule is processed.


   


var usergr = new GlideRecord('sys_user');  


  usergr.addQuery('sys_id', current.user);  


  usergr.query();  


  while(usergr.next())  


  {  


  usergr.vip = 'true';  


  usergr.update();  


  }   }



2016-05-03 14_09_11-ServiceNow.png


2016-05-03 14_08_39-ServiceNow.png


Please select insert and update checkbox to true.


Just a reminder that you may want to setup the opposite as well.


Removed from group, set VIP to false, just to keep your data clean.


I checked the INSERT and UPDATE but still no luck, the dictionary for VIP is called sys_user.vip



This is what it is targetting right? how would i add this to the code? to clean up after itself