Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to get the message in form when a async business rule is running

Anna_Servicenow
Tera Guru

I have the below scope SI and async BR . Its important that I show the message on form, but I am unable to do this as I am calling this from Asyn BR. How to fix this.

var AttachmentParserScoped = Class.create();
AttachmentParserScoped.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
    getExcelInfo: function(sysId, callback) {
  
        var currentSysId = sysId;
        var attachment = new GlideSysAttachment();
        var getdata = new GlideRecord('sys_attachment');
        getdata.addQuery('table_sys_id', sysId);
        getdata.addQuery('table_name', "x_fdrbl_business");
        getdata.query();
    
        if (getdata.next()) {
            //An attachment is found
            // ********Parsing the Excel to extract the data*******
            // ***** Create entries in  table******//
// Check if the username exists in sys_user table
                var userName = resolvedBy[i];
                var userDetail = new GlideRecord('sys_user');
                userDetail.addQuery('name', userName);
                           userDetail.query();
                              if (userDetail.next()) {
                    qualityControlList.resolved_by = userDetail.sys_id.toString();
                    qualityControlList.sub_team = userDetail.getDisplayValue('u_sub_team');
                    qualityControlList.parent_team = userDetail.u_parent_team;
                } else {
                    gs.addInfoMessage("Resolved by user not found: " + userName);
                }
                qualityControlList.case_id = caseID[i];
                qualityControlList.insert();
                       }
        } else {
            gs.addInfoMessage("Please attach a file to import the data");
        }
        callback();
    },
    type: 'AttachmentParserScoped'
});

Async BR:

(function executeRule(current, previous /*null when async*/ ) {
     new AttachmentParserScoped().getExcelInfo(current.getUniqueValue(), function() {
        current.import_state = 'Complete';
        current.update();
    });
})(current, previous);



5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@Anna_Servicenow If you really want to show these messages then convert the BR to an after BR.