- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 08:28 AM
Hi all,
I have one catalog item and it has one variable called "has_approval" and its type is "checkbox". If any user selects that checkbox, then the attachment should be mandatory. If the user selects the check box and if he didn't attach the attachment, then a pop up should show like "Please attach the attachment".
Can you please tell me how we should write the script.
Thank you
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 06:36 AM
Hi @Raghavendra ,
Please refer this thread it may help you. Verify Mandatory Attachments Count on Catalog Item
Kindly mark correct and helpful if Applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 10:31 PM
Hi
i have used the code which you has shared.When i click on the check box and if without any attachment if i submit the catalog item then i'm getting the error.
onSubmit script error: TypeError: Cannot read properties of null (reading 'getElementById'):
function () { [native code] }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 10:33 PM
Hi
i have used the code which you has shared.When i click on the check box and if without any attachment if i submit the catalog item then i'm getting the error.
onSubmit script error: TypeError: Cannot read properties of null (reading 'getElementById'):
function () { [native code] }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 10:48 AM
Hi @Raghavendra ,
you can create OnSubmit client script as below to achieve this.
if (g_form.getValue('has_approval') == true && !(g_form.getAttachment().length)) {
alert("Please attach the attachment");
return false;
}
return true;
Kindly mark my response correct and helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 10:23 PM
Hi Chetan,
I have tried with your code but when i click on the check box and even if i didn't attach tany attachment also the catalog is submitted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 06:36 AM
Hi @Raghavendra ,
Please refer this thread it may help you. Verify Mandatory Attachments Count on Catalog Item
Kindly mark correct and helpful if Applicable