AutoPopulate Field from drop down selection

riaz_mansuri
Kilo Guru

Hi,

I am trying to Auto Populate a field when a selection is a made from a drop down using client script.

My script which does not work is below. Any help would be appreciated.

So When "Risk Type" Corporate is selected the "Internal ref" should Auto Populate to CO000

Risk Strat.JPG

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

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

          return;    

  }    

 

  var svc = g_form.getReference('Corporate');    

  g_form.setValue('SR000', internal_ref);        

}    

Thanks

1 ACCEPTED SOLUTION

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


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


          return;


    }


var svc= g_form.getValue("u_risk_type");


alert('Outside'+svc);


if (svc == "Corporate") {


alert('Inside');


g_form.setValue("u_internal_ref", "CO000");


}


}


View solution in original post

21 REPLIES 21

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


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


          return;


    }


var svc= g_form.getValue("u_risk_type");


alert('Outside'+svc);


if (svc == "Corporate") {


alert('Inside');


g_form.setValue("u_internal_ref", "CO000");


}


}


Hi,



Thanks, I am lost of this. Changing the Risk Type still does not pre-populate the Internal ref.



Lost of ideas now, Service Now might have let me down for the first time


Thanks


Riaz


HiRiaz,



what is the value that you got in   alert(svc); ?


u_risk type is populated from some table? or just some values entered into the dropdown ?


If it is coming from any table ,then the value might be different. So give that value in the palce of corporate in


if (svc == "Corporate")   and try





Hi Ajai,



u_riskk_type is populated from a drop down list.



The Value is below, it is Corporate.


RiskTypeValue.JPG


I don't know much about alert(svc); I have added it as a recommendation above



Thanks,


Riaz


Are you getting any pop up while changing the value or not?