Mandatory Attachments on the Record Producer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2019 08:57 AM
Hi,
I want to make Attachments mandatory on the record producer (on the servicenow platform, not the portal).
I have written a client script using DOM. However, thats going to cause updrade issues. Please see the attached screenshot. My question is what is the alternative method? How can I use glideform API? Anyone has working code?
Thank you
- Labels:
-
HR Service Delivery

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2019 10:43 PM
Hi Shabnam,
Please Try to this code :-
- var sys_id = gel('sysparm_item_guid').value;
- var attachment = new GlideRecord('sys_attachment');
- attachment.addQuery('table_name','u_custom_table_name'); //my custom table is "u_custom_table_name"
- attachment.addQuery('table_sys_id',sys_id);
- attachment.query();
- if (!attachment.next()) {
- alert ("PLEASE ATTACH INVOICE.");
- return false;
- }
After going throw this Mark it Correct/helpful, if this helps you
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2019 10:47 PM
Hi
Try this code, sysparm wont work on portal and this will also work on desktop view -
var sysID = g_form.getUniqueValue();
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_name','sc_cart_item');
attachment.addQuery('table_sys_id',sysID);
attachment.query();
if (!attachment.next()) {
alert ("Attachment Required");
return false;
}
Hope this helps.
Regards
Omkar Mone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2019 11:02 PM
Hi,
Please go through the below article-
Thanks,
Vishal Khandve