How to limit the size of attachment for a particular ITSM module in servicenow?

Rachit_Sen
Tera Contributor

I want to minimize the size of attachment for just knowledge management module, How to do that?

3 REPLIES 3

AJ-TechTrek
Giga Sage
Giga Sage

Hi @Rachit_Sen ,

 

You can edit system property :

  1. Log in to the instance with an admin account
  2. Using the Navigator, browse to System Properties > Security.

    The Security Properties page for the instance will appear.  Locate the property on the page with the heading "Maximum file attachment size in megabytes". In this field, you can change the maximum allowed attachment size (in MB).

     

     



  3. Save.
    • The change will be reflected immediately on the instance.
  4. If the field is left blank (no value) the default limit (currently set at 1 GB) will be used as the maximum attachment file size.

For more info, Refer below

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0718101#:~:text=Description,o....

 

Please appreciate the efforts of community contributors by marking appropriate response as Mark my Answer Helpful or Accept Solution this may help other community users to follow correct solution in future.

 

Thanks

AJ

Linkedin Profile:- https://www.linkedin.com/in/ajay-kumar-66a91385/

Sumanth16
Kilo Patron

 

Hi @Rachit_Sen ,

 

You can however, write a script to restrict total size.   You can create a business rule before insert in sys_attachment table that checks the cumulative size of all attachments for a particular record. So lets say you are limiting size on the incident table. Something like:



var grInc = new GlideRecord('sys_attachment);

 

grInc.addQuery('table_name',"incident");//change table name

 

grInc.addQuery('table_sys_id',current.sys_id);

 

grInc.Query();

 

var totalSize=0;

 

while(grInc.next()) {

 

        totalSize+= parseInt(grInc.size_bytes);

 

}

 

if(totalSize+parseInt(current.size_bytes) > <your Size Limit>) {

 

        gs.addInfoMessage("Attachment size exceeded");

 

        current.setAbortAction(true);

 

}

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

Hi @Sumanth16 ,

 

Firstly thank you for your reply, but above code is not working, can you please clear my doubt that if I am just filling the record through (Knowledge article form) and adding attachments in that (right now our form data is not even saved),

than how we are using the gliderecord and searching for the attachment in the attachment table.

 

My problem statement is before saving the record I want to inform IT User that "Your Attachment size is more than 20 mb" something like that.

please tell me if I am wrong anywhere.