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

Dependent Dropdown does not save selection

New Here ,
Oct 05, 2020 Oct 05, 2020

Copy link to clipboard

Copied

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;

}

 

 

TOPICS
Create PDFs

Views

1.1K

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 ,
Oct 05, 2020 Oct 05, 2020

Copy link to clipboard

Copied

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"

 

 

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
Community Expert ,
Oct 05, 2020 Oct 05, 2020

Copy link to clipboard

Copied

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.

 

 

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 ,
Oct 06, 2020 Oct 06, 2020

Copy link to clipboard

Copied

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

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
Community Expert ,
Oct 06, 2020 Oct 06, 2020

Copy link to clipboard

Copied

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 ,
Oct 06, 2020 Oct 06, 2020

Copy link to clipboard

Copied

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? 

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
Community Expert ,
Oct 07, 2020 Oct 07, 2020

Copy link to clipboard

Copied

Look at the script in the shared document.

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 ,
Oct 07, 2020 Oct 07, 2020

Copy link to clipboard

Copied

I did and I have my script set up just like so I'm not sure why mines not working.  That actually is the document I used to initially create my dropdowns so I really have to think there is something else I'm doing that is making it not work properly.  unless you see something obvious that you can point out? 

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
Community Expert ,
Oct 08, 2020 Oct 08, 2020

Copy link to clipboard

Copied

Look at this part:

var val = this.getField(dependentListBoxFieldName).value;
this.getField(dependentListBoxFieldName).setItems(dependentListValues[event.target.value]);
try {
  this.getField(dependentListBoxFieldName).value = val;
}
catch (e) {
				
}

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 ,
Oct 08, 2020 Oct 08, 2020

Copy link to clipboard

Copied

I finally figured it out yahoo!  I think we are looking at the same part.  I deleted everyting at the bottom of the code (in red below is what I actually deleted) and it works. There must be something in there that is affecting it - I didn't initially pay attention to that part becuase it seemed to be directed toward list boxes which I'm not using.  either way I'm ecstatic it's working now!  I appreciate everyone's help on this!!! 

 

/*
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]);
}
}
else {
app.alert("This script was not intended for this field type or event.");
}

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 ,
Oct 08, 2020 Oct 08, 2020

Copy link to clipboard

Copied

Ok, I lied that did not fix it.  Now my lists aren't populating correctly argh! I'm trying to follow your code but I'm so new I don't know where to put it. I'll keep trying. thank you!

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
Community Expert ,
Oct 09, 2020 Oct 09, 2020

Copy link to clipboard

Copied

LATEST

Copy the script from the shared document.

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