Client script alert message based on catalog variable field

daniellethomson
Tera Expert

I have a request to create an alert message off a yes/no field for a service catalog item. Below is the script but it's not creating the alert. I'm very green in scripting- could someone look at it? Thanks!!

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {

          return;

    }

var chk = g_form.getValue('background_check');

  if (chk == 'No')

  {

  alert(getMessage("You must submit the background check to Vendor Management befoe proceeding"));

  }

}

6 REPLIES 6

Chuck Tomasi
Tera Patron

Hi Danielle,



There could be a few things to check... Is the Yes/No field value "No" or "no". That would impact your if statement.



Is the variable called background_check or is it u_background_check?



How about putting an else statement in there to display the value of chk just to display what you got for a value?


Abhinay Erra
Giga Sage

I believe the default value is No here. Did you try to change the field to Yes and then back to No which will trigger your code.


daniellethomson
Tera Expert

Thanks for the quick responses!



I confirmed the variable name and 'No.' I also tried selecting Yes and then back to No and it's still not triggering the code.


daniellethomson
Tera Expert

I figured it out- I needed to check mark apply in catalog item as well. Sorry for wasting your time. Thank you!