- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2011 10:17 AM
This post actually started out as a question, but as I was typing, I figured out what to do, so now I'm sharing... 🙂
We have an item that requires an attachment in order to fulfill the request, but I was not sure if it was possible to enforce. We could ask the user to confirm there is an attachment, but I could not see how to actually check it with code? Attachments are added to the sys_attachment table and associated with the sc_cart_item table, but there is no guarantee that the attachment is for that particular item, as the record stays around if the item is not actually added to the cart or ordered.
Then that "AHA!" moment struck - just check to see if the list of attachments is visible:
Here's the onSubmit script:
function onSubmit() {
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {
alert('You must attach at least 1 file before submitting this request.');
return false;
}
}
Solved! Go to Solution.
- 5,569 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2014 01:03 PM
Just setting this answer as correct as the actual thread was not meant as a question and it cannot be changed because it came from the original Community site.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2011 01:48 PM
You could still bypass the process by adding an attachment with a similar filetype to the system, which made it also insufficient. Appreciating the suggestion though 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2011 02:27 PM
You could check the file name itself, but not really the contents.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2018 05:32 AM
Good morning I did the same procedure that you could not yet,
when I request the form it appears the message to insert,
and when I insert an attachment continues sending message to insert the attachment,
being that in the table or the attachment is the, Could you help me solve it?
follow my script
function onSubmit() {
var cat_id = ('sysparm_cart_edit').value;
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_name,', 'sc_cart_item');
gr.addQuery('table_sys_id', cat_id);
gr.query();
if (!gr.next()) {
alert("É obrigatório anexar um comprovante para finalizar a solicitação.");
return false;
}else{
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2013 07:01 AM
This came in handy!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2014 01:03 PM
Just setting this answer as correct as the actual thread was not meant as a question and it cannot be changed because it came from the original Community site.