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-17-2022 11:40 PM
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-17-2022 11:51 PM
Hello,
In the transform map please check if the run business rule checkbox is set to true.
Also make sure there are no transform script in that transform map which has the below syntax:-
setWorkflow(false);
Also wondering instead of using business rule why not use a advance qualifier as below:-
javascript: 'user_id='+current.Manager_user_id;
Please mark answer correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2022 12:46 AM
Hello,
You do not need a business rule you can do it using advance reference qualifier.
Open the dictionary of the userRef field and add the below line in the advance qualifier:-
javascript: 'user_name='+current.u_id;
Please mark answer correct/helpful based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2022 12:42 AM
but it is a refernece qualifier I want that field to be updated with that record.
And this is reference to the same table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2022 01:03 AM
The manager_user_id is one field right and and manger_Identity is one field so if I am understanding it correctly it should work fine. Can you give it a try?
javascript: 'user_id='+current.Manager_user_id;