- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 07:48 PM
Hii All
i am writing this script in catalog item to know that item has attachment attached or not on submit client script but
error getting
below is the code
function onSubmit() {
// Check if attachments exist
var attachment = g_form.getAttachmentList();
if (attachment.length > 0) {
// If attachments are found, allow submission
alert('Attachments found.');
return true;
} else {
// If no attachments found, prevent submission and prompt user
alert('Please attach a file.');
return false;
}
}
when i order item error occure Error MessageonSubmit script error: TypeError: g_form.hasAttachmentList is not a function:
function () { [native code] }
glide record and script include not to use is here anyone who can solve the issue now
Solved! Go to Solution.
- Labels:
-
Benchmarks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 04:21 AM
HI @dheeru_1994 please try to second approach
Script: onSubmit
Note: Ensure Isolate Script field is set to False for this Catalog Client Script to ensure DOM manipulation works
function onSubmit() { //Type appropriate comment here, and begin script below var countRequired = 1; if(window == null){ // portal if(this.document.getElementsByClassName('get-attachment').length != countRequired) { alert('You must add 1 attachments before submitting this request.'); return false; } } else{ // native view var length = $j("li.attachment_list_items").find("span").length; if(length != countRequired){ alert('You must add 1 attachments before submitting this request.'); return false; } } }
Please mark reply as Helpful/Correct, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2025 10:52 PM
@dheeru_1994 did you get the solution of this? I also have similar requirement and don't see any option.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 01:57 AM
You can use out of box "Mandatory Attachment" checkbox under Portal Settings tab of Catalog Items.
You don't need to write code for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 01:09 AM
Is there any way of doing it without DOM manipulation and with GlideAjax