Business Rule to retrieve value from another table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2020 11:31 PM
I need a Business Rule to retrieve value from another table. The 2 tables are:
[syslog_transaction] table
- user_name: UserA
- remote_ip: 10.1.2.3
and
[sysevent] table
- sys_created_by: UserA
- u_ip_address_from_transaction_log: (should be auto-populated using BR by referencing "remote_ip" in [syslog_transaction] table)
After a record is created in [sysevent] table, the custom field "u_ip_address_from_transaction_log" should be auto-populated by referencing "remote_ip" field in [syslog_transaction] table which has same user name. (Please see the image below)
For this requirements, I wrote the following BR, but it didn't work and the custom field was not populated. Please kindly check where the problem is.
*after insert/update BR in [sysevent] table:
(function executeRule(current, previous /*null when async*/) {
var gr=new GlideRecord("syslog_transaction");
gr.addQuery("sys_created_by",current.user_name);
gr.query();
if(gr.next()){
current.u_ip_address_from_transaction_log = gr.remote_ip;
gr.update();
}
})(current, previous);
*Filter Conditions is "[Name] is [attachment.read]"
Best Regards,
Aki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 12:15 AM
Hello,
Just change the BR from insert/update to only update and try the below code -
(function executeRule(current, previous /*null when async*/) {
var gr=new GlideRecord("syslog_transaction");
gr.addQuery("sys_created_by",current.user_name);
gr.query();
if(gr.next()){
current.u_ip_address_from_transaction_log = gr.remote_ip;
//gr.update();
}
})(current, previous);
Let me know if this helps.
Regards
Omkar Mone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 12:36 AM
Hi Omkar,
Thank you for your reply. I changed as you suggested, but the field was still not populated..
Is there other possible solution?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 12:39 AM
Can you try using getter setter functions?
Make change in line
current.u_ip_address_from_transaction_log = gr.remote_ip;
to
current.setValue("u_ip_address_from_transaction_log",gr.getValue("remote_ip"));
Hope this helps.
Regards
Omkar Mone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 12:47 AM
Hi Aki,
It seems that your username is populated once the record is inserted.
So Can you try this approach to make the BR to after BR (i.e its not best practice but try)
Try the below script:
(function executeRule(current, previous /*null when async*/) {
gs.log('@inside BR '+ current.user_name);
var gr=new GlideRecord("syslog_transaction");
gr.addQuery("sys_created_by",current.user_name);
gr.query();
if(gr.next()){
gs.log('@inside loop '+gr.remote_ip);
current.setValue('u_ip_address_from_transaction_log',gr.remote_ip);
current.update();
}
Make sure that user_name is populated in the form once the record is inserted.
Please mark helpful and correct.
Thanks,
Cb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 01:02 AM
Hi CB,
I changed the BR to after insert/update and tried your script, but I got the same log and the user_name was not resolved..