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.

How to set 1Mb for picture attachment in a form level

krishna svg
Tera Contributor

How to set 1Mb for picture attachment in a form level

1 REPLY 1

Ramz
Mega Sage

Hi @krishna svg ,

If you want to do it globally use this KB article and modify the system property and set the size you want:

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

 

If you want to do it to only on a particular table/form and particular type of attachment format write a before insert BR on sys_attachment table:

 

var grInc = new GlideRecord('sys_attachment');
grInc.addQuery('table_name',"incident");//change table name according to your requirement
grInc.addQuery('table_sys_id',current.sys_id);
grInc.Query();
var totalSize=0;
 while(grInc.next()) {
      totalSize+= parseInt(grInc.size_bytes);
}
if(totalSize > 1) {
        gs.addInfoMessage("Attachment size exceeded");
        current.setAbortAction(true);
}

 

This code is not tested.Please use log messages to and correct your code accordingly.

 

Please mark my answer helpful/correct if it resolved your query