Validate attachment befor submitting service request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2022 12:09 AM
Hello community leaders,
We have requirement that, when we submit the request in xxxx catalog item, email approval attachment is mandatory from requestor manager. For this we have written on submit client script. It is working fine but if requestr attach empty attachment also it is allowing to submit the request..
Now challange here is, can we validate attachment if it is blank it shouldn't allow to submit, if it is have something then it should allow to submit the request..
Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2022 12:34 AM
Hi there,
What's your definition of empty? Because for example, an new/blanc xlsx file, will actually not be empty, it will have some content. So what's your definition? Or what kind of attachments are you after? Etc..
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2022 12:08 PM
Hi Vinay,
As Mark mentioned above, we need to know your definition of empty to suggest approaches that fits your nee.
Metadata of attachments are stored in sys_attachment table, if you query that table you can identify the size of the attachment.
But if your problem is related to end users adding empty screenshots, we cannot control that behavior.
A blank or white page screenshot still occupies space since the pixels in image stores the white color code and it occupies space on disc.
An alternative approach I would like to suggest is add an attachment type variable, make it mandatory as per your needs and only allow file extensions of type, .eml, .msg, .email, .emlx (Which should cover most common email extensions in windows and apple systems).
In the variable, you may choose to provide instructions on how to download or copy emails from outlook, exchange or webapp or workspace mail or mac, and also inform them that an incorrect attachment could cause cancellation of the request.
Instead of pdfs or image files we can ask users to provide actual email messages, so that there is less chance of providing incorrect approval files as attachments.
This approach may work fine, if the target audience are IT users, but if the catalog item is exposed to non IT end users then it may not be suitable for you and may need to allow users to add even PDFs or image files.
If you want to check this approach on using attachment type variable and you haven't used it before, here are the example screenshots on how to use it.
You can find additional information on this here at below link regarding attachment type catalog variable:
https://docs.servicenow.com/bundle/quebec-servicenow-platform/page/product/service-catalog-management/reference/r_VariableTypes.html#d265662e84
Or alternatively provide help text or instructions and let end user know that, an incorrect or blank attachment may lead to the cancellation of request by fulfillment teams.
Hope this helps!
Thanks and regards,
Subrahmanyam Satti