Client script alert message based on catalog variable field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2016 10:48 AM
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"));
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2016 10:51 AM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2016 10:52 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2016 11:53 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2016 12:03 PM
I figured it out- I needed to check mark apply in catalog item as well. Sorry for wasting your time. Thank you!