Async BR and After BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2024 02:09 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2024 02:19 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2024 02:28 AM - edited 02-17-2024 11:44 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2024 04:51 AM - edited 02-18-2024 04:54 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2024 04:57 AM - edited 02-18-2024 04:57 AM
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!