Async BR and After BR

Rooma1
Tera Contributor

HI All,

 

Can we use a Async BR instead of After BR in the below scenario:

 

 

Suppose I want to generate a Problem records just after the Incident state changes to On Hold and On Hold Reason changes to Awaiting Problem and it should show a message at the top of the incident page with the Problem record number.

 

Thanks,

Rooma

5 REPLIES 5

Anand Kumar P
Giga Patron
Giga Patron

Hi @Rooma1 ,

Yes you can use asynchronous br instead after br  Instead of doing everything immediately, create async rule that works in the background. using this approach, things happen without slowing down the Incident form, giving users a smoother experience.

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

Andrew_TND
Mega Sage
Mega Sage

Hi @Rooma1 

 

Yes, you can use an asynchronous Business Rule instead of an after.

 

However, keep in mind that using an async BR means the Problem record generation and message display won’t be immediate. It might take a little time for the message to appear, depending on system load and other factors.

 

(function executeAsync(current) {
if (current.state == 'on_hold' && current.on_hold_reason == 'awaiting_problem') {

var problemgr = new GlideRecord('problem');
problemgr.initialize();
problemgr.short_description = 'Problem related to Incident: ' + current.number;
var problemSysId = problemgr.insert();

 

gs.addInfoMessage('A Problem record (' + problemSysId + ') has been created for this Incident.');

 

current.problem_id = problemSysId;
current.update();
}
})(current);

 

Please mark as helpful or if it’s resolved the issue, CORRECT!

Hi @Andrew_TND I tried this code and I am getting the sys_id of the Problem over the Info message. How to get the Display Value of the Prb number. I tried getDisplayValue() method but isn't working. I also tried 'problemSysId.toString()', this is also not working.

 

And also wanted a hyperlink to that Problem created.

 

Can you please let me know how to convert it.

 

Thanks,

Rooma

Hi @Rooma1 

Try this…

 

(function executeAsync(current) {
if (current.state == 'on_hold' && current.on_hold_reason == 'awaiting_problem') {
var problemgr = new GlideRecord('problem');
problemgr.initialize();
problemgr.short_description = 'Problem related to Incident: ' + current.number;
var problemsysid = problemgr.insert();

 

var problemno = problemgr.number.toString();

gs.addInfoMessage('A Problem record (' + problemno + ') has been created for this Incident.');

current.problem_id = problemsysId;
current.update();
}
})(current);

 

Please mark as helpful or if it’s resolved the issue, CORRECT!