• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Drop down menu: Options set via custom calculation, resets to default (top) selection

New Here ,
Jan 28, 2021 Jan 28, 2021

Copy link to clipboard

Copied

I've created a form we use for employee provisioning for multiple companies and have created a dropdown that is using a custom calculation to set the options based on the company name that is entered to for the list of available branches. When entering the company name the drop down changes as expected, setting the "please select" option as the selected option (first open defaults). After selecting an option from the menu and clicking into any other fields, the drop down reverts back to the original "please select" value. Script below. I tried setting it up as a switch/case script as well with the same results. Any advice on a better way to generate this list and prevent it from reverting to the top option in the list would be greatly appreciated!

 

var coBranchOpts = this.getField("Company").valueAsString;
if (coBranchOpts=="Company1")
{
event.setItems([
"Please Select a branch from the options below",
"Address 1",
"Address 2",
"Address 3",
"Other - Please add comments in the 'Special Instructions' field"
]);
}
else if (coBranchOpts=="Company2")
{
event.setItems([
"Please Select a branch from the options below",
"Address 1",
"Address 2",
"Address 3",
"Other - Please add comments in the 'Special Instructions' field"
]);
}
else if (coBranchOpts=="Company3")
{
event.setItems([
"Please Select a branch from the options below",
"Address 1",
"Address 2",
"Address 3",
"Other - Please add comments in the 'Special Instructions' field"
]);
}
else if (coBranchOpts=="First Excel Title, LLC")
{
event.setItems([
"Please Select a branch from the options below",
"Address 1",
"Address 2",
"Address 3",
"Other - Please add comments in the 'Special Instructions' field"
]);
}
else if (coBranchOpts=="Enter Company Name")
{
event.setItems(["Please select the company first"]);
}
else
{
event.setItems(["Company not found - Please add comments in the 'Special Instructions' field"]);
}

TOPICS
JavaScript , PDF forms

Views

199

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 28, 2021 Jan 28, 2021

Copy link to clipboard

Copied

Move the code to the field's Validation event and change the first line to:

var coBranchOpts = event.value;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 28, 2021 Jan 28, 2021

Copy link to clipboard

Copied

LATEST

That got it! When I was testing and moved the script from the branch calculation to the company validation I forgot to change the first line. You're my rockstar today :D.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines