Skip to main content
Known Participant
October 5, 2020
Question

Dependent Dropdown does not save selection

  • October 5, 2020
  • 2 replies
  • 2599 views

I have a dependent dropdown that does not save your selection after you save the form and reopen it.  I'm not sure it's in an error with the code for this drop down or if the list before it is preventing it from saving.  Form is attached but general functionality is:

 

Dropdown 1 Selection (Carrier)

Dropdown 2 (Product) - items dependent upon selction in Dropdown 1

Text Fields  - text fields appear based on the selection in dropdown 2. 

 

(Carrer) Dropdown 1 has code in Format Tab, Custom, Custom Format Script

(Product) Dropdown 2 has code in Format Tab, Cusom, Custom Format Script

 

I tried moving both codes to Custom Calculation Script but then Dropdown 2 doesn't change list items based on Dropdown 1 selection. 

 

I'm at a loss!  Thank you!   Form attached in case anyone wants to take a look.  

 

 Carrier dropdown code: (this is from a sample form I found so I very well could have done it wrong)

dependentListBoxFieldName = "dependentDropdown";
var dependentListValues = 
{
	"AIG": [
         ["Product"],
         ["Platinum Choice VUL 2", "Platinum Choice VUL 2"],
	    ["Secure LifeTime GUL 3", "Secure LifeTime GUL 3"],
		["Select-A-Term", "Select-A-Term"]
	],
	"John Hancock": [
    ["Product"],
		["Protection VUL 17"],
		["Protection UL 19"],
		["Protection Term"]
	],
	"Lincoln": [
["Product"],
		["VULOne", "VULOne"],
		["SVULOne", "SVULOne"],
],
	"Pacific Life": [
["Product"],
		["Harbor VUL", "Harbor VUL"],
		["Promise GUL"],
],
	"Protective Life": [
["Product"],
		["Strategic Objectives VUL"],
		["Advantage Choice UL"],
["Classic Choice Term"],

],
	"Prudential": [
["Product"],
		["VUL Protector"],
		["PruLife Custom Premiere"],
["Term Essential"],
		
	]
};
/*
You probably don't need to change anything from here down
*/
if ((event.target.type == "combobox" && event.name == "Format") || (event.target.type == "listbox" && event.name == "Keystroke")) {
	if (event.target.type == "combobox") {
		if (dependentListValues.hasOwnProperty(event.target.value)) {
			this.getField(dependentListBoxFieldName).setItems(dependentListValues[event.target.value]);
		}
		else {
			this.getField(dependentListBoxFieldName).clearItems();
		}
	}
	if (event.target.type == "listbox" && dependentListValues.hasOwnProperty(event.changeEx)) {
		this.getField(dependentListBoxFieldName).setItems(dependentListValues[event.changeEx]);	
	}
}

 

Product dropdown code (it's really long so this is just a snippet of what I have)

if (this.getField("dependentDropdown").value=="Platinum Choice VUL 2") {

    this.getField("AIGProspectus").display=display.visible;
}

if (this.getField("dependentDropdown").value=="Protection VUL 17") {

     this.getField("AIGProspectus").display=display.hidden;
}

if (this.getField("dependentDropdown").value=="VULOne") {

     this.getField("AIGProspectus").display=display.hidden;
}

if (this.getField("dependentDropdown").value=="SVULOne") {

     this.getField("AIGProspectus").display=display.hidden;
}

if (this.getField("dependentDropdown").value=="Harbor VUL") {

     this.getField("AIGProspectus").display=display.hidden;

}

if (this.getField("dependentDropdown").value=="VUL Protector") {

     this.getField("AIGProspectus").display=display.hidden;

}

if (this.getField("dependentDropdown").value=="Strategic Objectives VUL") {

     this.getField("AIGProspectus").display=display.hidden;

}

 

 

This topic has been closed for replies.

2 replies

Bernd Alheit
Community Expert
Community Expert
October 6, 2020
Known Participant
October 6, 2020

Now that you mention that, you are absolutley right!  That is the exact form I took my the code from so that is weird it won't save for me.  In the sample form, it stops after dependentDropdown.  I added the additional code for Text boxes to populate based off the depdentDropdown selection.  Do you think something in that code is maybe to blame?  Maybe the fact the code contains hidden/visible text boxes prevents it from saving the dropdown selection? 

Bernd Alheit
Community Expert
Community Expert
October 7, 2020

Look at the script in the shared document.

ls_rbls
Community Expert
Community Expert
October 5, 2020

I think that in the first line of the dropdown field "Carrier" :

 

dependentListBoxFieldName = "dependentDropdown";

 

Should read: 

// your dependent dropdown field
dependentListBoxFieldName = "Product";

 

That should be run as custom format script of the "Carrier" dropdown field.

 

Then in the custom kestroke section of "Carrier" dropdown fild add a script for the dependent textfields like:

if (event.willCommit){this.getField("myTextField").value=event.changeEx;}

 

Also, make sure that in the "Carrier" dropdown "Options" tab to select "Commit selected value immediately"

 

 

ls_rbls
Community Expert
Community Expert
October 6, 2020

I forgot to add to my reply, that in order for the custom keystroke script to work with the desired textfields, you also need to add a line of custom calculation script on the dependent text field(s) that will get that value from the dependent dropdown "Product".

 

For example:

 

event.value = this.getField("Product").value;

 

This line could be elaborated with more complex scripting, but if all you need is the text field to populate with the secondary value of the script, the line above works.

 

By this I mean that the text fields will autopopulate with the second value if it is defined  in your script above.

 

Not all the dependent list items in your script have a second value though.

 

So in this case, nothing will populate in the text fields if the selection made in dropdown "Carrier" contains only one listed value in that script. In this particular case only dropdown "Product" will populate, but not the text fields.

 

 

Known Participant
October 6, 2020

I tried these but still getting the same result.  Not sure I did it right 😞