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-15-2020 11:45 PM
Hello Aki,
Let us add few logs and check first if your Br is executing or not. I am not sure if the entry is inserted into transaction by the time this BR is executed.
(function executeRule(current, previous /*null when async*/) {
var gr=new GlideRecord("syslog_transaction");
gs.log("Current user name is "+current.user_name);
gr.addQuery("sys_created_by",current.user_name);
gr.query();
if(gr.next()){
gs.log("Entered into your if condition"+gr.remote_ip);
current.u_ip_address_from_transaction_log = gr.remote_ip;
gr.update();
}
})(current, previous);
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 12:09 AM
Hello asifnoor,
Thank you for your advice. I temporarily changed the BR to what you gave me here, but could you tell me where I can check the log to confirm if the BR ran successfully or not?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 12:13 AM
Hi,
In your left navigation -> System logs -> All
There add a filter to run by last 15 mins and sort by created desc order and check it.
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 12:31 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 12:57 AM
So as per logs, username is empty. So check if the username column is having any value or not in that table.