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 09:32 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 10:07 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:21 PM
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
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 10:09 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.