How to populate values in User profile BU and Business Unti column based on User Group membership

e__rajesh_badam
Mega Guru

Hi Every one,

 

Need help in below scenario to achieve,

 

In my Account User getting created and adding into Group 'X'.

The requirement is Based on user group membership need to populated value in Business Unit and BU column.

 

Note: Both BU and Group details we are pulling it from sys_user_group table only.

 

 

 

 

e__rajesh_badam_0-1742995494879.png

 

2 ACCEPTED SOLUTIONS

@e__rajesh_badam 

then do this

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var gr = new GlideRecord("sys_user_group");
    gr.addQuery("sys_id", current.group);
    gr.query();
    if (gr.next()) {
        var userRec = current.user.getRefRecord();
        userRec.u_business_unit = current.group.name; //COGS is the group name here
        userRec.u_bu = current.group;
        userRec.update();
    }

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

@e__rajesh_badam 

Keep the same script, update the BR condition as this

current.group.name == 'GLO-COGS ServiceNow SSO Users'

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Hi @Ankur Bawiskar , thanks for all the help and final code here for reference

 

Business rule is : AFTER with INSERT

 

e__rajesh_badam_0-1743066421281.png