Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Set a variable with default value based on another variable

bijender1
Tera Contributor

Hi,

We need to set up one variable with different values based on another variable on the joiner form.

Variable "Team"  type select box . if select box is IT.  then another variable "shareddrive" of type " multi line text" will show default value as " this is the default drive IT team needs access"

and if 

select box in Team variable is HR, then the same another variable " shareddrive" of type " multi line text" will show default value as " this is the default drive HR Team needs access"

Regards,
B

 

7 REPLIES 7

rad2
Mega Sage

Writing an onChange client script would help in this case

bijender1
Tera Contributor

Hi,

Tried that but not working, default value is not updating, please can you help in writing that.

code i used:

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

if (g_form.getValue('Team')=='it') {
g_form.setDefaulyValue('ATSDept',"this is the default drive IT team needs access");


}

}

find_real_file.png

find_real_file.png

 

Hello,

Do verify if the field name or Question Name is 'Team'. and also the value of the choice is 'it'

 

Also, use setValue instead of setDefaulyValue

g_form.setValue('ATSDept',"this is the default drive IT team needs access");