- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 08:10 AM
Hello All,
I'm trying to populate a selectbox variable based on a single line text field. As we can see in the below image, I'm trying to autopopulate dropdown choice based on a single line text field value. As you can see in the below image, but below script, it's not working as expected. Can someone help me with corrections to the script?
LAN ID == Single line Text variable
Domain == Dropdown/selectbo
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var lanId = g_form.getValue('lan_id');
lanId = ["ACCPT", "AF", "AP", "EA", "NA", "SA", "UPSTREAMACCTS"];
if (lanId.indexOf('ACCPT') !== -1) {
g_form.setValue('domain', 'ACCPT');
} else if (lanId.indexOf('AF') !== -1) {
g_form.setValue('domain', 'AF');
} else if (lanId.indexOf('AP') !== -1) {
g_form.setValue('domain', 'AP');
} else if (lanId.indexOf('EA') !== -1) {
g_form.setValue('domain', 'EA');
} else if (lanId.indexOf('NA') !== -1) {
g_form.setValue('domain', 'NA');
} else if (lanId.indexOf('SA') !== -1) {
g_form.setValue('domain', 'SA');
} else if (lanId.indexOf('UPSTREAMACCTS') !== -1) {
g_form.setValue('domain', 'UPSTREAMACCTS');
}
}
Thanks,
JRY
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 08:21 AM - edited 10-25-2022 08:23 AM
Hi @JRY
Can you try this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var lanId = g_form.getValue('lan_id');
//lanId = ["ACCPT", "AF", "AP", "EA", "NA", "SA", "UPSTREAMACCTS"]; //commented this line
if (lanId.indexOf('ACCPT') >-1) {
g_form.setValue('domain', 'ACCPT');
} else if (lanId.indexOf('AF') >-1) {
g_form.setValue('domain', 'AF');
} else if (lanId.indexOf('AP') >-1) {
g_form.setValue('domain', 'AP');
} else if (lanId.indexOf('EA')>-1) {
g_form.setValue('domain', 'EA');
} else if (lanId.indexOf('NA') >-1) {
g_form.setValue('domain', 'NA');
} else if (lanId.indexOf('SA') >-1) {
g_form.setValue('domain', 'SA');
} else if (lanId.indexOf('UPSTREAMACCTS') >-1) {
g_form.setValue('domain', 'UPSTREAMACCTS');
}
}
Hope it works
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2022 12:51 AM
Hello,
Can you elaborate a little that what is your use case? Like do you want to show the options as dropdown? But I see for every option you are setting only one dropdown so why not just make it a string field and populate it.
If you could elaborate a little it would be easier to help.