The CreatorCon Call for Content is officially open! Get started here.

gs.addInfoMessage not showing up on (government Service) Portal in Before Insert BR on attachment.

ParamP
Tera Contributor

This is my code - 
As an admin,  while on playbook experience on Portal, I can see the addInfoMessage instantly, when needed. But as a constituent, non SNC Internal role, on portal the mesage does not show up instantly, it shows up when the window is refreshed. Below is my code.

 

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var MAX_SIZE = 10490314;
    var mimeTypeArray = [];
    var propertyValue = gs.getProperty('attachment.allowed');
    if (propertyValue) {
        // Split the property value by commas and push it to an array
        mimeTypeArray = propertyValue.split(',').map(function(mimeType) {
            return mimeType.trim(); // Trim spaces around each MIME type
        });
    }
    var val = mimeTypeArray.indexOf(current.getValue('content_type'));
    if (val == -1) {

        gs.addInfoMessage("infoMsg");
       
        current.setAbortAction(true);
        gs.setRedirect(current);
    }
    if (current.size_bytes > MAX_SIZE) {
        gs.addErrorMessage('File size exceeds the maximum allowed size of 10MB.');
        current.setAbortAction(true);
    }

})(current, previous);
 
 
I have also tried removing and adding 'gs.setRedirect(current);' in the if, but it makes no difference.
5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@ParamP 

so your business rule is running but for snc_external info message is not showing?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

The business rule is running, the attachment uploading is aborted (as I need it to), the alert does not show up instantly, but when I refresh the portal page, it shows up (as a constituent).
As an admin, everything happens, and the alert shows instantly as expected.

@ParamP 

you are testing with which user? snc_external?

it's weird

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

 sn_gsm.constituent (related to PSDS module). It's an external user role.