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

How to add values to a dropdown upon initialize


Level 2

I am creating a dropdown list - where users can choose the proper year of business.

This dropdown needs to be customized to the user:

  • Values begin at the year the business began to generate hazardous waste
  • I need to add values for each year - up to the current year.

I want the current year to be calculated instead of static.

How do I add values to a dropdown list?

In LiveCycle - I would do something like this:


for (var i=dateBaseYear.rawValue; i<=dateCurrentYear.rawValue; i++)



this.addItem("" + i); //needed to add a string in front of 'i'.  not sure why


Is there a similar solution for AEM Forms?

0 Replies


Employee Advisor

Hi John,

I guess you are working with adaptive forms, you should use rule editor to set the values in drop-down list. Please refer Adobe Experience Manager Help | Adaptive forms rule editor.




Level 2

I have saved the Guide and refer to it constantly.

Is there an example that I can reference?  I cannot seem to find out to add each value - via the rule editor.



Employee Advisor

I will create some sample script and share with you shortly.


Level 2


Any progress?  Looking forward to seeing an example.




Employee Advisor

Hi John,

Somehow I missed this thread, did you got this sorted out already?


Level 7

The DropDownList can be programmatically populated in the initialise event using an array of key=value pairs [1] on the items property [2]. So for your particular example, to populate the list starting at the current year and running for 5 years would look something like:

(on the initialise event)

var currentYear = (new Date()).getFullYear();

this.items = [];

for (var i = 0 ; i < 5 ; i++) {

  this.items.push(i + "=" + currentYear-- + " Item Name");


The above code will add 5 entries to the drop down list

0=2018 Item Name

1=2017 Item Name


4=2014 Item Name

When the item is selected, the key will be stored in the field property. If you want the value stored instead, then just leave out the key= part to the item string when you are adding it to the items array.

[1] Adobe Experience Manager Help | Adaptive Form Expressions

[2] Adaptive Forms Class: GuideDropDownList