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-17-2020 12:08 AM
Hi CB,
Thank you for your reply.
The API call in this context is just the way I download an attachment on the KB article. By default, that action will automatically create Event record and Transaction Log record.
If I should customize the default api settings or some script for this, please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 12:45 AM
Hi Aki,
I don't think its possible as I checked in my PDI and at the time of creation it is not having the values, I guess after some time its updating the value through some other calls.
And we don't have access to the API from which they are creating the record in the event table using the attachment.
And you have to do a lot of customization to create a new API from the attachment which is attached in knowledge article and it won't even possible.As the trigger point is when we click on the attachment present in the knowledge form.
So better push back the requirement as writing a BR on event would cause a performance issue in future or you can raise HI ticket to get some solution the API is not accessible for us.
Please mark helpful and correct.
Thanks,
CB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 01:51 AM
Hi CB,
Thank you so much for testing in your instance.
Then, can we set sleep time (maybe 30 seconds) in the BR to wait for the "user_name" field to be updated by API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 02:11 AM
Hi Aki,
The sleep will also not work in that case. I tried usign the sleep as well then you will see only hearbeat events not the attachment read event.
glide.heartbeat
This event will come after putting the sleep but not the attachment read.
I guess there is something strange with this event. We are not getting the control on this via BR in any of the case i tried with async, after and all but nothing is coming up.
I guess in someplace of the attachment read they have written the setWorkflow(false) so that is why its not coming and we are not having acess to it.
So if you tried all the way you can't get the values in the BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 01:18 AM
Hi CB,
Thank you for your confirmation.
I asked HI to check SNow specifications of Event API and to give me the solution to the issue we are facing.
Once I get an answer from HI, I will share that with you.
Best Regards,
Aki