Auto Populate multiple choice option based on the requested for country
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2024 02:49 AM
Hi Team,
We have one multiple-choice "type" variable with two radio button options (Remote, Office).)
If requested for the country is US then the type should be auto-populate as "remote" and should be read-only.
I tried with the on-change client script but this is not working for me
var user = g_form.getReference('requested_for', doAlert); // doAlert is our callback function
function doAlert(user) { //reference is passed into callback as first arguments
if(user.u_country_ref == "dd38b7111b121100763d91eebc0713f5") //sys id of united state of America country
{
g_form.setValue("type","remote);
g_form.setReadOnly("type",true);
alert("pass");
}
else{
g_form.setValue("type"," ");
g_form.setReadOnly("type",false);
alert("fail");
}
Can someone please help me here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2024 09:28 AM
Hi @lucky24
In the code, change to Like this, I think You forgot to ";
g_form.setValue("type","remote");
Thanks and Regards
Sai Venkatesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2024 09:30 AM
Hi @lucky24 ,
You can use this script in the onChange client script. It'll work.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var user = g_form.getReference('caller_id', doAlert);
function doAlert(user) {
if (user.country == "US") {
g_form.setValue('u_permises', 'remote');
g_form.setReadOnly('u_permises', true);
} else {
g_form.setValue('u_permises', 'office');
g_form.setReadOnly('u_permises', false);
}
}
}
Change the US to your sys_id and change the field name. Please let me know if you've any questions.
Please mark the answer helpful, if it helped you accordingly.
Regards,
Hari