Auto populate value based on variable select variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 09:20 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 10:37 PM
Use this -
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '') {
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');
}
return;
}
var sender = g_form.getValue('backend_name_of_sender_field');
if(sender){
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 09:37 PM
Hi,
Create one onchange catalog client script on sender field
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '')
return;
if ((newValue == 'usb')||(newValue=='windows')) {
g_form.setValue('receiver', 'text');
} else {
g_form.setValue('receiver', 'call');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 09:44 PM
Hello @Krishna Priya ,
You can use onChange client script :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 10:08 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 10:19 PM
Hi @Krishna Priya ,
Are you setting any default choice value for "Sender" variable?
Regards
Jyoti Jadhav