how to set Attachment Mandatory in Service portal cataloque item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 11:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 11:52 PM
Hi,
Create a onSubmit client script
Please refer below script and replace the variable names as per the requirement
function onSubmit() {
//Works in non-portal ui
var data_master_val = g_form.getValue('data_master');
var opr_val = g_form.getValue('operation');
if (data_master_val == 'Customer' && opr_val == 'New ') {
try {
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
alert('Please attach the document before submitting this request.');
return false;
}
}
//For Service Portal
catch (e) {
var count = getSCAttachmentCount();
if (count <= 0) {
alert('Please attach the document before submitting this request.');
return false;
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 11:53 PM - edited 09-12-2023 11:56 PM
Hello @Srinivasu2, on the catalog item creation form, there is a portal setting section from there you can make attachments mandatory without writing a single line code.
regards,
Abhijeet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 11:58 PM
this is required for native or portal?
Check my blog and enhance the script as per your requirement
Verify Mandatory Attachments Count on Catalog Item
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 12:03 AM - edited 09-13-2023 12:04 AM
Hi you need to follow the link to implement the same.Check below URL
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0743672
Harish