Auto populate value based on variable select variables

Krishna Priya
Tera Contributor

Auto populate value based on variable

I have two variables called sender and receiver.

In sender, choices are mail, usb, windows, land, laptop

Receiver choices are text and call.

 

If i choose sender either usb or windows, i want to populate the Receiver has text.

 

Please help me with script in catalog client script.  

12 REPLIES 12

Harsh_Deep
Giga Sage
Giga Sage

Hello @Krishna Priya 

 

Use this OnChange script-

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

   //Type appropriate comment here, and begin script below
var sender = g_form.getValue('backend_name_of_sender_field');
if(sender=='usb' || sender=='windows'){
g_form.setValue('backend_name_of_reciever_field','text');
}
else{
g_form.setValue('backend_name_of_reciever_field','call');
}
}

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

I have tested it. But only its working on on change, if i choose initially, the value is not getting populated. But if i change its working.

I want to populate the value if they select initially also.

In else case if want to include none , which is default option. Please suggest on that.

@Krishna Priya ,

Please use this below Script 

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

   //Type appropriate comment here, and begin script below
var sender = g_form.getValue('backend_name_of_sender_field');
if(sender=='usb' || sender=='windows'){
g_form.setValue('backend_name_of_reciever_field','text');
}
else{
g_form.setValue('backend_name_of_reciever_field','call');
}
}

Regards,

Shyamkumar

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

@Harsh_Deep  

I have tested it. But only its working on on change, if i choose initially, the value is not getting populated. But if i change its working.

I want to populate the value if they select initially also

In else case if want to include none , which is default option. Please suggest on that.