Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

AEM Forms 6.3 DropDown List appends items on new assignment

Maruan_Sahyoun
Level 2
Level 2

I'm running AEM Forms 6.3 and experience an issue when dynamically populating a dropdown.

On initialize of a certain field I add an array of items to the dropdown using DropDown.items = array. Now when the filed changes I'd like to replace the items with another set of items. That doesn't work. The new items are appended so the drop down list get's longer. What's strange is that the newly created set of items can be changed but the original assignment is always kept.

Further more printing DropDown.items to the console the correct items show up.

To further illustrate that

# initial assignment - 5 items - DropDown list contains 5 items visually - DropDown.items.length = 5

# new assignment - 3 items - DropDown list contains 8 items visually - DropDown.items.length = 3

Verified in Chrome and Firefox.

We are running AEM Forms JEE - SP1 - available patches are installed.

1 Accepted Solution
James_R_Green
Correct answer by
Level 7
Level 7

I can reproduce this when a dropdown list is bound.

The error doesn't occur when the dropdown is unbound.

Tested this on 6.2 and it doesn't append the values (which is what I would expect), to me the functionality has changed between 6.2 and 6.3 and I don't know why you would want it to work the way it appears to work in 6.3 so I personally think this is a bug.

A few options:

* if two dropdowns (dropdownA and dropdownB) are bound to the same field, and you set dropdownB.items = ["A=A","B=B","C=C"]; - dropdownB exhibits the appending you have reported *but* dropdownA does not. You could use this to your advantage and hide dropdownB - not pretty, but if you are desperate for a workaround it might help. It will also depend how many dropdowns you have on your form whether this is a viable option.

* Or similarly use an unbound field on the form and copy the value to a bound copy of the field on submit.

* Otherwise, try creating a custom widget for dropdownlist and see if that has the same issue.

View solution in original post

9 Replies
smacdonald2008
Level 10
Level 10

Are you following an online doc for this - can you point the community to that to see if that can be reproduced.

Maruan_Sahyoun
Level 2
Level 2

This happens only for an XFA template based adaptive form. The DropDown list is bound to the XFA based data model. Creating an adaptive form from scratch doesn't show that behavior.

smacdonald2008
Level 10
Level 10

That is interesting. Question is if there is a bug or is there something that is missed when setting up the XFA model. I have asked the AEM Form team to look here.

Maruan_Sahyoun
Level 2
Level 2

Btw. this is a very simple Options Expression I used for testing. Other events show the same behaviour.

if (Anwendungsfall.value == 1) {

  this.items = ["A=A", "B=B", "C=C", "D=D", "E=E"];

} else {

  this.items = ["A=A", "B=B", "C=C", "D=D", "E=E"]; 

}

jagjeetthukral
Level 3
Level 3

I don't think this is a bug.

There is a point we are missing here, since that field is mapped to an XFA element, it is supposed to have values that only XFA dropdown is mapped to.

The right approach to handle your scenario should be to have the dropdown dynamic in XFA itself. The process remain almost similar to what you are doing in Adaptive Forms

Hope this helps !!!

Cheers,

Jagjeet Singh

AEM Forms Blog

Maruan_Sahyoun
Level 2
Level 2

So what you are saying is that the scripting should go to the XFA Template?

Btw. it did work in AEM Forms 6.2.

James_R_Green
Correct answer by
Level 7
Level 7

I can reproduce this when a dropdown list is bound.

The error doesn't occur when the dropdown is unbound.

Tested this on 6.2 and it doesn't append the values (which is what I would expect), to me the functionality has changed between 6.2 and 6.3 and I don't know why you would want it to work the way it appears to work in 6.3 so I personally think this is a bug.

A few options:

* if two dropdowns (dropdownA and dropdownB) are bound to the same field, and you set dropdownB.items = ["A=A","B=B","C=C"]; - dropdownB exhibits the appending you have reported *but* dropdownA does not. You could use this to your advantage and hide dropdownB - not pretty, but if you are desperate for a workaround it might help. It will also depend how many dropdowns you have on your form whether this is a viable option.

* Or similarly use an unbound field on the form and copy the value to a bound copy of the field on submit.

* Otherwise, try creating a custom widget for dropdownlist and see if that has the same issue.

View solution in original post

Maruan_Sahyoun
Level 2
Level 2

Hi James,

thanks for taking the effort and also providing a workaround solution. What we ended up with is to remove the binding on the field and pass the selected information in another field.

Moving forward we'll go with schema binding anyway.

Many thanks also to Scott and Jagjeet for looking into that.

With kind regards

Maruan

smacdonald2008
Level 10
Level 10

Glad james was helpful. This is the point of the AEM community. To try and help as much as possible.