- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 12:58 PM
On our Service Portal, we have a Record Producer that creates a SAFE Epic (sn_safe_epic) record. Through integration, these records are being transferred over to Azure DevOps upon submission into ServiceNow.
The issue is that under certain scenarios, the users are required to attach a file to the Record Producer record on the Service Portal before submitting. We want to not allow them to submit the request if they have not attached any required files.
Unfortunately, it does not appear that we can use the "Attachment" field type on the Record Producer, as for some reason, ServiceNow will not send these attachments over to Azure Dev Ops. However, if we use the out-of-the-box "Add Attachments" link at the bottom of all forms on the Service Portal, ServiceNow will send over those attachments to Azure Dev Ops.
We are fine with doing that, but how can we create a Catalog Client Script to verify that they have actually attached a file before allowing them to submit?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2025 05:34 AM
you can use this onSubmit catalog client script and it will work in both native + portal
Example: if variable ABC has value as XYZ then make the attachment mandatory
Please enhance it as per your requirement
function onSubmit() {
//Type appropriate comment here, and begin script below
var variableValue = g_form.getValue('ABC');
try {
if (window == null) {
// portal
if (this.document.getElementsByClassName('get-attachment').length == 0 && variableValue == 'XYZ') {
alert('You must add attachment before submitting this request.');
return false;
}
}
} catch (ex) {
// native view
var length = getSCAttachmentCount();
if (length == 0 && variableValue == 'XYZ') {
alert('You must add attachment before submitting this request.');
return false;
}
}
}
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
02-25-2025 06:42 AM
Thanks, but we are going with Ankur Bawiskar's solution since it works for us, and is self-contained to the Catalog Client Script.