Update a field under reference field using BR

ss123
Tera Contributor

Hi All,

 

We have a requirement wherein, whenever there is a new record or a record is updated in this table 'Resource Allocation Daily', a field from the reference 'User' field will be updated using BR, but seems our BR is not working or maybe we are missing something?

 

For example: 

This record RA0001 has a reference field called "User" and in that user value has an "Adoption" field. So whenever RA0001 is updated the User.Adoption will have a value of 100.

Same goes to when a new Resource Allocation Daily record is created / inserted.

 

Note that if RA0001 is updated, and the user in the record is User123, then the User123.Adoption value should be 100.

 

Thanks in advance for all your help.

 

6 REPLIES 6

J Siva
Tera Sage

Hi @ss123 
Share the picture of your existing configuration.
Regards,
Siva

ss123
Tera Contributor

Hello @J Siva here's the current config. Thanks.

ss123_0-1746498939064.png

 

ss123_1-1746498953968.png

 

@ss123 I don't think you can dircetly set the ref field's field value like this.
Use the advanced option and scripts to fulfill your requirement. Try the below script.

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

    var alloc_user = current.getValue('<User field name from Resource allocation daily table');
    var user = new GlideRecord('sys_user');
    user.get(alloc_user);
    user. < adoption field name >= "100";
    user.update();

})(current, previous);

JSiva_0-1746500497953.png

 

@ss123 

you can have after update BR on "Resource Allocation Daily" table

Condition: Keep your existing condition

Script: Something like this but please enhance

(function executeRule(current, previous /*null when async*/) {
    // Get the User record referenced in the current record
    var userGR = new GlideRecord('sys_user');
    if (userGR.get(current.userField)) {
        // Update the Adoption field to 100
        userGR.adoptionField = 100;
        userGR.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