Issue with Async Business Rule

RiteshSwarnakar
Giga Guru
Hi ServiceNow Experts,
 
I just want to understand why the below script is not working in Async Business Rule:
 

 

var gb = new GlideRecord('cmdb_ci');
    gb.addEncodedQuery('correlation_id=test');
    gb.query();
    if (gb.next()) {
        gs.log('yes', 'BR_test');
    }

 

 
Note:
I have created this business rule on custom import set table.
I have tested this using After BR and it is working fine as expected.
The requirement is to run with Async Business Rule only
 
 Can someone please let me know what is the issue here?
 
8 REPLIES 8

Hi @RiteshSwarnakar 

 

first, please replace your log statement with

gs.info('BR_test');

as your version is deprecated and shouldn't be used any longer.

 

Then one thing to consider: A "after" Business Rules runs as the authenticated user in it's session context. However, an "async" Business Rule runs as the "system" user in the background and thus decoupled from the current user's session. And there is also no guarantee when that async Business Rule is running. ServiceNow creates a scheduled job for each execution of an "async" Business Rule. So maybe you have not waited long enough to see the output in the syslog table.

 

Maik

Narsing1
Mega Sage

Async BR's will run on its own based on the system performance at that particular time.  This means your log statement may not appear immediately after you execute the import set procedure.

If this BR is in a scoped app, use gs.info instead of gs.log.

Try to increase the priority to 900 and see. 

But I am not really sure what would you like to accomplish here

 

Thanks,

Narsing

Thanks @Narsing1 , for your inputs. I tried your suggestions but still same issue.

Ok.  Would like to know the complete code of your BR.  from the given script, you are always checking the correlation id as "test".  Also, a sample record of your custom importset table.

Thanks,

Narsing