Aborting Attachment

Prathyusha G
Tera Contributor

My requirement is to abort insertion of attachment on case table when attachment size exceeds 9MB and throw an error message.

Error message is throwing as expected but the null attachment is showing.

1 ACCEPTED SOLUTION

@Prathyusha G 

the null attachment message should not show

is this happening for all users everytime?

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

View solution in original post

7 REPLIES 7

Karina11
Tera Contributor

What about changing the properties for attachments, where you can define max size of an attachment? Maybe that way it would be easier. 

Hi Karina,

 

Thankyou for response. Size limit is only on case table. If I change properties it will affect all tables.

Ankur Bawiskar
Tera Patron
Tera Patron

@Prathyusha G 

share what script have you written for this along with screenshots.

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

 Hi Ankur,
Added the below code
if (parseInt(current.size_bytes) > 9000000) {
        gs.addErrorMessage(gs.getMessage("There is a file size limit of 9MB. Please choose a smaller file"));
        current.setAbortAction(true);
    }
 
Above code is added on before insert business rule by adding table name in filter condition on attachment table.