Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Hide submit button in catalog form

Abdul
Tera Contributor

i have a situation where in when a user selects no for a variable the form should not be submitted in catalog form, how can we achieve this?

1 ACCEPTED SOLUTION

M Iftikhar
Tera Sage

@Abdul ,

Create an onsubmit client script by modifying below code to prevent form submission.

function onSubmit() {
    var answer = g_form.getValue('your_variable_name'); // replace with actual variable name

    if (answer == 'no') {  // value should match the variable's internal value, not label
        alert("You cannot submit this form if 'No' is selected. Please change your response.");
        return false;  // stop submission
    }

    return true; // allow submission
}
Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

View solution in original post

1 REPLY 1

M Iftikhar
Tera Sage

@Abdul ,

Create an onsubmit client script by modifying below code to prevent form submission.

function onSubmit() {
    var answer = g_form.getValue('your_variable_name'); // replace with actual variable name

    if (answer == 'no') {  // value should match the variable's internal value, not label
        alert("You cannot submit this form if 'No' is selected. Please change your response.");
        return false;  // stop submission
    }

    return true; // allow submission
}
Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.