- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2015 12:04 PM
Hi,
We have a requirement where we should prevent resolving a ticket if the total size of the files attached to the ticket is more than 18 MB and show a pop-up instead alerting the agent about the file size.The reason is that we attach all the attachments to the outgoing email whenever the ticket is resolved . ServiceNow does not send email notifications if attachments size is more than 18 MB. This has resulted in emails being blocked and landing in the 'Failed' Mailbox and the end user never gets informed that the ticket is resolved.
If you have any suggestion to solve this scenario, please share your input.
Thanks in advance for looking into this!
Best Regards,
Shalini
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2015 12:38 PM
Shalini,
You can query sys_attachment for the current record using a "Before" business rule to check the total size of the attachments before you resolve the incident.
Basically, you'd want the business rule to go something like this:
var totalsize = 0;
var attachment_size = new GlideRecord('sys_attachment');
attachment_size.addQuery('table_sys_id', current.sys_id); //this queries for the attachments for the current record
attachment_size.query();
while (attachment_size.next()){
totalsize =+ attachment_size.size_bytes; //returns the total size of attachments in bytes.
}
var totalsize_MB = totalsize / 1000000; //converts the total size to MB
if(totalsize_MB > 18){
gs.addErrorMessage('The total size of attachments exceeds the maximum allowed (in MB). Please remove attachments and try again.'); // error message
current.setAbortAction(true); // stop the form submission
}
...or something along those lines. You'll probably need to tweak it a bit to get it to work in your instance (and to fix any bugs I have in there).
(Edit to highlight the code snippet as JavaScript for easier reading)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2015 12:45 PM
Thanks for you reply Mike! This is a very good suggestion. I work on the business rule and see how it works in our enviroment.
Cheers,
Shalini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 11:43 AM
Hello Mike, is there a way to have pop-up with the message about the size instead of adding an error message. Business rules do not allow the pop-ups, so I guess I'll have use a client script. Do you have any suggesions?
Thanks,
Shalini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 11:55 AM
Shalini,
You're right about not being able to use alerts/confirms from a BR, so you're limited to info/error messages at the top of the screen. One thing you could try would be to have the BR set a hidden true/false on the form (call it "attachments size exceeded"), then have an onSubmit client script that checks for that flag, if it exists, THEN you can have an alert that lets the end user know that the attachment size is too large, and therefore the form cannot be submitted.
The only downside to this approach (in my opinion) is that it would require adding another field to your form, albeit a hidden one.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 11:56 AM
Hi Shalini,
Please check the below link on how to alert from business rule.
http://www.evanios.com/site/servicenow_popup_alert_box_business_rule/
I hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 12:09 PM
I'm going to throw my vote in for Pradeep's method here....and probably use it in the future!