Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Error massage is not working in workspace in compose email but working in classic view.

Brijmohan
Tera Contributor

I am getting an unexpected error in compose email in supplier workspace. I have written one BR on sys_attachment table to restrict attachment size more then 10 mb. It it working fine when I open the compose email from classic view but when I go to workspace and then open compose email and try to add more then 10 mb file it is giving below error message.

Brijmohan_0-1694845305103.png

But in classic view it is giving actual error.

Brijmohan_1-1694845360122.png

 

Below is my before insert BR that is on sys_attachment table and and it will run when target table is sn_supplier_case OR sys_email OR sys_email_draft.

 

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

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

    // These are the properties 
    var ProcFileType = gs.getProperty('slmFileType.ext');
    var ProcFileSize = gs.getProperty('slmFileSize.size');

    // This a calculation based on the property being in MB.

    var MaximumFileSize = ProcFileSize * 1000 * 1000;

    //Get the values from the file being uploaded
    var fileSize = current.getValue('size_bytes');
    var fileType = current.getValue('content_type');

    //Split the array from the property into each file type
    var ProcFileTypeSpl = ProcFileType.split(',');

    //If the current file type does not match a value in the split or the file size is too large, abort.
    if ((ProcFileTypeSpl.indexOf(fileType) == -1) || (fileSize > MaximumFileSize)) {
       gs.addErrorMessage(gs.getMessage('Restrict SLM Attachments'));
       // gs.info('Brij error msg');
                                //current.setWorkflow(false);
        current.setAbortAction(true);
    }


})(current, previous);

})(current, previous);

Please help me out here if someone know about this. 

Thanks in advance!

 

Regards,

Brijmohan

2 REPLIES 2

AnveshKumar M
Tera Sage
Tera Sage

Hi @Brijmohan ,

Refer the following link, it may help you.

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0714677

 

Thanks,
Anvesh

Hi @AnveshKumar M , Thanks for your response. My BR is working fine in classic view even in workspace view if I am attaching any document from attachment option but when I am trying to attach any file from compose email add file option my error message is not showing there. I think it is related to some workspace issue.