Display error message for attachment mandatory

Priyanka145
Tera Contributor

Hi ,

I m having a catalog item, attachment should be mandatory.

I have set it up in portal settings.

But I want the error message to be displayed like "kindly attach migration document". Please let me know how to customise the error message if attachment is not added while submitting the catalog item 

1 ACCEPTED SOLUTION

shyamkumar VK
Kilo Patron

Hello @Priyanka145 ,

Use the below "OnSubmit" client script

and make sure to set Isolate script: False on client script / catalog client script.

 

 

 

function onSubmit() {
    if (this.document.getElementsByClassName('get-attachment').length == 0) {
    g_form.addErrorMessage('kindly attach migration document.');
        return false;
    }
}

 

 

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

View solution in original post

4 REPLIES 4

shyamkumar VK
Kilo Patron

Hello @Priyanka145 ,

Use the below "OnSubmit" client script

and make sure to set Isolate script: False on client script / catalog client script.

 

 

 

function onSubmit() {
    if (this.document.getElementsByClassName('get-attachment').length == 0) {
    g_form.addErrorMessage('kindly attach migration document.');
        return false;
    }
}

 

 

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

Would you rather prefer "this.document. ..." instead of using ".getValue()":

 

function onSubmit() {
    if (g_form.getValue('get-attachment').length == 0) {
        var getName = g_user.getFullName();
        g_form.addErrorMessage('kindly attach migration document.');
        return false;
    }
}

 

This one worked for me as an alternative to our default error message that displays with the mandatory attachment.

Thanks!

shyamkumar VK
Kilo Patron

Hello @Priyanka145 ,

did you get chance to test my solution for your requirement?

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar