g_form.setValue not working on Variable set

Jeffce
Tera Expert

I have the below script set to run on load to automatically set a selectbox, it does not seem to be working, Does anyone know if this will not work on a variable set? I only have two choices available Values 1 and 2

 

 

 

function onLoad() {

    //Type appropriate comment here, and begin script below

g_form.setValue('install_group',2)  

}

1 ACCEPTED SOLUTION

Jeffce
Tera Expert

I got it fixed, thank you all for your help, turned out to be a corrupt variable set, I had to rebuild it and it is working now.



JJ


View solution in original post

5 REPLIES 5

Dan_Berglin
Giga Expert

Hi,


try this:



function onLoad() {


    //Type appropriate comment here, and begin script below


      g_form.setValue('variables.install_group',2)


}


Rohit Khaire
Mega Contributor

Hi ,


use variables or variable_pool object and then use to set value to particular variable set variable .


Dan_Berglin
Giga Expert

If the choice value is an int:


g_form.setValue("variables.install_group", 2 )




If the choice value is a string:


g_form.setValue("variables.install_group", "2")




If the target field is a reference I would also recommend specifying the displayvalue in order to avoid extra server call.


g_form.setValue("variables.install_group", "sys_id", "displayValue")


justin_drysdale
Mega Guru

Like others are saying, the variable name is probably the issue.   Try just alerting on it to see what you get?



alert(g_form.getValue('install_group'));



Does it pop up undefined or blank?   If it does the variable name is probably the issue.