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

Hi @nebula,

 

Select the variable name that you have created. It will work.

Take a look at - Catalog client scripts / Client scripts 

 

Note-  onChange() — runs when a particular field value changes on the form. The onChange() client script must specify these parameters/ field/ variable.

 

Thanks,

Sagar Pagar

The world works with ServiceNow

@Sagar Pagar thank you for your support. When I go to the Field name drop down, it does not show the variable name I had created in the list. If I go to the portal, it does display so I know it is active.

Hi @nebula,

 

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

 

Thanks,

Sagar Pagar

The world works with ServiceNow

That was it!! A very valuable lesson I've learned. Thank you @Sagar Pagar for your support!

Mike_R
Kilo Patron

Try this

 

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

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

}