Update a field under reference field using BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 06:55 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 08:16 PM
Hi @ss123 ,
we can not set the value of different table using set field values
change the BR to run as after BR and check the advance checkbox and update the script with below
var user = current.user.getRefRecord();
if (user.isValidRecord()) {
user.setValue('u_adaption', 100); /*assuming the u_adaption is the name of the field update the name of the field if needed*/
user.update()
}
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2025 09:05 PM
you can have after update BR on "Resource Allocation Daily" table
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader