Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

onChange Client Script does not create a popup

nebula
Tera Guru

Hey everyone,

I have a service catalog item where I created a new Yes/No field called "Have you tried the "Forget Your Password" option on the SF Login Site?" If the user selects "No" then a popup should display with directions.

 

I created an onChange client script and it does not do anything. I've confirmed that Active and Global are checked, the UI type is All, it's in the sc_cat_item table, type is onChange, and the script is below. What could I be missing?

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

//User selects NO, this is the message they see
if (newValue === 'have_you_tried_the_forget_your_password_option_on_the_sf_login_site' == NO){
alert(getMessage('Please use the password reset from the SF Login Site before submitting this request.'));
}

}

 

Thank you!

1 ACCEPTED SOLUTION

Hi @nebula,

 

Make sure you have created Catalog Client scripts instead if Client scripts.

 

Thanks,

Sagar Pagar

The world works with ServiceNow

View solution in original post

9 REPLIES 9

Sagar Pagar
Tera Patron

Hi @nebula,

Try this updated scripts -

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}

	//User selects NO, this is the message they see
	if (newValue == "NO") // add correct value no/ NO { 
		alert(getMessage('Please use the password reset from the SF Login Site before submitting this request.'));
}

}

Thanks,

Sagar Pagar

The world works with ServiceNow

Unfortunately, it did not work. 

To confirm, (and should have mentioned in the original post), I have checked my browser's pop-ups so I know it cannot be that.

Hi,

Make sure you have selected the correct field/variable in field on catalog client scripts form.

 

Thanks,

Sagar Pagar

The world works with ServiceNow

Good catch - I have the Field Name as --None--.  Is there a generic option to select for that field since I had created the variable? I'm trying to understand the Field name function but am having trouble finding online resources.