How to display an error message when condition(s) are no me

ID NOBLE
Tera Expert

Please I have a requirement to display an error message "Must provide a reason(s) for your selection".

 

We have a variable of type "SELECT BOX" with options: True, False, Unknown. So, when a user select "False" from these options, the above error message (in red color) must automatically display to users. Please how do I do this?

 

Thanks.

1 ACCEPTED SOLUTION

@ID NOBLE 

 

You can make use of an On-Submit Catalog Client Script. Please refer below screenshots :

AmitVerma_0-1733893530043.png

 

 

function onSubmit() {
    var userChoice = g_form.getValue('user_choice'); // Please replace with your catalog variable
    if (userChoice == 'false') {
        g_form.addErrorMessage('Please provide a reason for your selection before submitting');
        return false;
    }
}

 

 

AmitVerma_1-1733893587402.png

 


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

12 REPLIES 12

have you written any object so far, either catalog client scrip or catalog UI policy/action as example given by @Amit Verma , If yes, please share the screen shot of those pages. 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

@AshishKM,

 

I used the method suggested by @Amit Verma and it actually displayed the error message. However, I was still able to submit the form even with the displayed error message which we don't want

Its allowing to submit because there is no restriction applied to stop form submission.

You can try with onChange script with return false statement and mark the field mandatory.

Or write onSubmit and check the field value and return false to stop form submission.

 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi @AshishKM ,

 

Can you please help me with that?

 

Thank you.

@ID NOBLE , i see your issue resolved by @Amit Verma example code. 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution