Make attachment mandatory when check box is selected

Raghavendra
Tera Expert

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

1 ACCEPTED SOLUTION

Hi @Raghavendra ,

                                    Please refer this thread it may help you. Verify Mandatory Attachments Count on Catalog Item 

Kindly mark correct and helpful if Applicable

View solution in original post

9 REPLIES 9

@Basheer 

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] }

@Basheer 

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] }

Chetan Mahajan
Kilo Sage
Kilo Sage

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

@Chetan Mahajan 

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

Hi @Raghavendra ,

                                    Please refer this thread it may help you. Verify Mandatory Attachments Count on Catalog Item 

Kindly mark correct and helpful if Applicable