How to restrict the attachment file size from 1024MB to 25MB

Srinivasu2
Tera Contributor

Hi Community,

 

I have written record producer for case form on CSM Portal 

As of now OOB file size attachment is allowed up to 1024MB, but the requirement is to restrict to 25MB

 

Could you please provide the steps to restrict file size from 1024MB to 25MB

 

Srinivasu2_2-1716901187141.png

 

Thanks,

Srinivasu

 

3 REPLIES 3

Community Alums
Not applicable

Hi @Srinivasu2 ,

 

You can call the script include & in script include you can query attachment table. In attachment table you will have size field. Based on that you can abort action.

Sai149_0-1716902650336.png

If my answer helped you in any way, please mark it as helpful or correct.

palanikumar
Mega Sage

Please follow the below steps:

1) Go to "System Properties > Security"

2) Update "Maximum file attachment size in megabytes" to 25

3) Click Save button

Thank you,
Palani

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Srinivasu2 

In case you want to have a specific limit for any   you can write a business rule on sys_attachment table (Before Insert).

 

(function executeRule(current, previous /*null when async*/) {
  if(parseInt(current.size_bytes) > 1000000 && current.table_name == 'incident')
{
//Abort the insert if size is greater than 1MB --> 1000000bytes
gs.log('Size has been exceeded');
current.setAbortAction(true);
}
})(current, previous);

 

 

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

 

Regards,

Sid