Business Rule - Async on insert Gliderecord on related table sometimes returns undefined

Jonas VK
Tera Guru

Hi all,

I am running into an issue with a business rule that runs async insert.
When I run the business rule, it triggers a script include that does a glide record to items in the related list of that record. I have noticed that I sometimes get a return that it doesn't find an item in this related list.
Sometimes it works fine, but I need to get the data from that related list reliable.

 

Is there a way I could either delay the business rule by a short time (1 second is already plenty, since that is the delay sometimes between the 2).

Thanks in advance,
Jonas

5 REPLIES 5

Divya85
Kilo Expert

@Jonas VK wrote:

Hi all,

I am running into an issue with a business rule that runs async insert.
When I run the business rule, it triggers a script include that does a glide record to items in the related list of that record. I have noticed that I sometimes get a return that it doesn't find an item in this related list.
Sometimes it works fine, but I need to get the data from that related list reliable.

 

Is there a way I could either delay the business rule by a short time (1 second is already plenty, since that is the delay sometimes between the 2).

Thanks in advance,
Jonas


If your BR is running on insert ,then relation to other table(related list target table) may not already be made,so try wait function in script include

Laszlo Balla
ServiceNow Employee
ServiceNow Employee
gs.sleep(1000); //duration in ms, this is 1 second

works in the global scope, but depending on what your planned outcome actually is, there might be a better way to go about this, e.g. perhaps having the BR on the table of the related items with different conditions?

This BR is in a scoped application, so this might not work.
Unfortunately, I have to trigger from here due to other data that gets handled on here related to this.

Regards,
Jonas

You can create a global SI with the sleep function in it which could be called from other scopes, as described in this support article.