How to set a value on a single text field or select box field, after selecting a choice from another variable?

alberttagle
Tera Contributor

Hi,

I'm trying to script, so that when I choose an option in two different select box variables (Environment and Version), the "target server" variable will have a specific text (for single line text), or maybe set the choice if I use select box.

I have done the following so far:

find_real_file.png

find_real_file.png

 

 

1 ACCEPTED SOLUTION

Double check your using the correct field names in your getters and setters. Also add some alerts throughout the code to see where the script is breaking.

I have a feeling this could be the condition which triggers the client script. You want to change the variable name to either environment or version. This way the client script is triggered when one of those is changed, not onChange of the target server field.

View solution in original post

9 REPLIES 9

Dylan Mann1
Giga Guru

In order to get the value of the environment and version fields you'll want to use g_form like so:

var env = g_form.getValue('db_environment');
var ver = g_form.getValue('dbversion');

Also keep in mind when getting and setting choice fields, you're getting the value of that choice not the label. So if the value of SQL Server 2014 is '3', you'll want to change your if statements to reflect that value. If you were to set that choice fields value, you'd do it like so: g_form.setValue('dbversion', '3');

Let me know if this helps,

Dylan

Hi, Dylan.

Thanks for replying.

Regarding the Choice fields, I have entered the value and the label to be exactly the same.

I tried to change the var script to the one you suggested, but it didn't work.

The target server field does not change to DKCDCSQL096.

Double check your using the correct field names in your getters and setters. Also add some alerts throughout the code to see where the script is breaking.

I have a feeling this could be the condition which triggers the client script. You want to change the variable name to either environment or version. This way the client script is triggered when one of those is changed, not onChange of the target server field.

Hi Dylan.

The latter suggestion made it work!!!! THANKS A LOT!!!