Client script to show an alert at certain choice list value?

eliana_wise
Tera Contributor

Hi,

I have wrote the onChange client script that I want an alert to pop up when the data protection type is   US, and apparently it doesn'y work. Can some one advise me on this?

Thanks

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

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

          return;

    }

var dtype = g_form.getValue('u_data_protection_type')   ;

if (dtype == 'u_dp_us' ) {

alert('Test');}}

1 ACCEPTED SOLUTION

You can use the below script:



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


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


          return;


    }



var dtype = g_form.getValue('u_data_protection_type')   ;



if (dtype == 'sys_id' ) { // Replace sys_id with the sys id that you got.


alert('Test');}


}


View solution in original post

10 REPLIES 10

Have you tried the code I provided? This should work.


Thanks this Worked.


eliana_wise
Tera Contributor

Hi Nisha,



Thanks for your reply, but when I tried this it gives me an error message.


Screen Shot 2017-08-30 at 1.24.23 PM.png



why don't you use the newValue in if clause.



 


Thanks.


PS: Hit like, Helpful, Correct, if it answers your question.


I tried this just now and the message didn't pop up.