- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2014 02:59 PM
Is there a way to check for attachments in the current form and making attachment mandatory if a field is checked ?
Solved! Go to Solution.
- Labels:
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2014 10:59 AM
Hi Ankit Lohani
Try the below script,If you are looking for mandatory attachments on catalog item.
function onSubmit() {
var cat_id = gel('sysparm_item_guid').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("You must attach a file to submit.");
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2015 12:57 PM
Would g_form.getParameter("sysparm_item_guid") be a better way to get the guid? Being that gel is getting the value from the DOM, which we know to avoid wherever possible. In this case it might not make a difference?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2016 08:30 AM
Hi Pradeep
Can you please help with how to check when something is attached to record and when attachment is removed.
I have a requirement to show alert on Knowledge form when something is attached and when something is removed when I save or update record.
Regards,
Waqas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2016 10:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2014 08:40 AM
There is a gliderecord routine hasAttachments():
http://wiki.servicenow.com/index.php?title=GlideRecord#hasAttachments
However, as others have alluded to, there are times when you may need to check the attachments table directly.