Prevent submission of a service catalog item if a boolean variable is false.

Daniel Unsworth
Tera Contributor

Hi I was hoping someone could help with an onSubmit() client script?

The script is to prevent a catalog item from being submit if a boolean variable is false with a simple alert.

 

I get the alert and the the item won't allow me to submit which is what it should do but if the variable is true then

it still behaves like it's false. The script is below. I've tried else, else if with a return true but that just cancels out the return false. Script below:

 

function onSubmit() {
//Type appropriate comment here, and begin script below
if (atgm_user == 'no') {
alert ('You cannot submit this request if you are not an ATGM user.');
return false;
}

}

 

Any help greatly appreciated 😊

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

The syntax on both looks fine.  Let's temporarily add an alert at the beginning to answer the question of what value is detected for this test case:

function onSubmit() {
    var atgm = g_form.getValue('atgm_user');
    alert(atgm);
    if (atgm == 'false') {
        alert(getMessage('You have to be an ATGM user in order to use PDMLink with CREO. You cannot submit this request if you are not an ATGM user.'));
        return false;
    }
}

 

View solution in original post

6 REPLIES 6

You are welcome!

Daniel Unsworth
Tera Contributor

.