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

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

auto increase number to fill field


Level 5

Hi All.

Is it possible to create field in a form where number will incrase by 1 automaticaly each other time when form will open? I will appraciate for sample.


1 Reply


Level 10


If you are opening the same instance of the form then you could add some JavaScript code like;

var autoNumber = xfa.datasets.resolveNode("formState.autoNumber");

if (autoNumber == null)


    // If our 'formState' dataset does not exist then create it with a value of zero.

    var formStateXML = <formState><autoNumber>0</autoNumber></formState>;

    var formState = xfa.datasets.createNode("dataGroup", "formState"); // Note the 'formState' in this line becomes the top node not the 'formState' in the XML






    // If our 'formState' dataset does exist then increment the autoNumber property.

    autoNumber.value = (parseInt(autoNumber.value,10) + 1).toString(); // Can only assign strings to a dataValue object


This will create a customs dataset, called formState in this script, sort of like a custom data connection.  Once this is setup then you can reference it in your field using


Here is an example,

Hope this helps