How do you call out looking for an attachment in a catalog client script onSubmit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2024 01:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2024 01:37 PM
Hello @NadiaR
I use the following onSubmit catalog client script on one of my record producers, let me know if it helps.
function onSubmit() {
// Get attachment count
var attachmentListElement = this.document.getElementsByClassName("get-attachment");
var attachmentCount = attachmentListElement.length;
// Add an error message if there are no attachments and cancel submit
if (attachmentCount == 0) {
getMessage("Please add an attachment", function (msg) {
g_form.addErrorMessage(msg);
});
return false;
}
}
Let me know if this works!
Kind regards,
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2024 08:44 AM
Hi Brian!
The above worked thank you but, the message still displays when an attachment does exists. Here is the code I'm using. Do I need to change my if statement?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2024 09:32 AM
You need to return false instead of true in your script.
By the way: Why don't you add a Variable of Type Attachment and make it mandatory? This would make such a script obsolete...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2024 10:20 AM
I hear ya but, they want the client to be able to still submit the request. Thanks for the feedback though.