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 01:13 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 01:51 AM
Hello Aki,
Is your BR written on sysevent table or transaction?
Can you share the complete BR screenshot which shows conditions, tablename and the code.
This should help us to debug the issue faster.
Mark the comment as helpful if it helps to debug the issue.
Regards,
Asif
2020 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 02:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 02:16 AM
Hi,
did you check if it is populated during insert?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2020 02:28 AM
Hi,
Also since it is after update you need to use current.update() instead of gr.update()
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader