how to Set field value in reference field using BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2022 11:50 PM
Hi,
How to set reference field value using Business rule?
I have 2 fields on a custom table
u_id-String
UserRef-reference to sys_user
I want Business rule code that when u_id is filled or updated it should go glide record using u_id field to match UserId in sys_user table and that record should be updated in UserRef

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2022 12:03 AM - edited ‎10-14-2022 12:04 AM
Hi,
Something like this perhaps?
var userID = current.getValue('u_id');
var userGR = new GlideRecord('sys_user');
if (userGR.get('user_name', userID)) {
current.setValue('u_user_ref_field_name', userGR.getUniqueValue());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2022 11:45 PM
Hi @OlaN
I have a custom table u_accounts
fields are:
User_id
first_name
last_name
Manager-String
manger_Identity-Refernce to self table(u_accounts)---not visible on form
Manager_User_Id-String---not visible on form
I have written after business rule on insert/update with condition Manager_User_Id changes
var gr=new GlideRecord('u_accounts');
gr.addQuery('user_id',current.Manager_user_id);
gr.query();
if(gr.next()){
current.manger_Identity=gr.getValue('sys_id');
}
current.update();
It is working fine if i submit using form but it is not working when i upload data in bulk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2022 12:17 AM
How do you upload data in bulk?
Through an import set?
If so, did you uncheck "run business rules" on the transform map?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2022 01:23 AM - edited ‎10-18-2022 01:23 AM
Hi @OlaN
The checkbox is true
I assume the problem is the manager record is not present while that record is being inserted.
But again, if it is after business rule then after all the records are inserted it is running then it should find the records