Skip to Content
Author's profile photo Varun Vadnala

Incrementing the Counter dynamically in Adobe forms using Java script.

Increment of Numeric Values using Javascript in SAP Adobe forms.

We might come across certain situations where we need to increment the numeric counter

  1. Dynamically.

For example:

We have a table of contents in order

1 – A

2 – B

3 – C

4 – D

5 – E

Here the counter is starting from 1 to 5 depending on the respective alphabets (In real world dynamic Values).

If we have a requirement to display only:




Then the corresponding counter should be as :

1 – A

2 – C

3 – E

But not as

1 – A

3 – C

5 – E.

In order to deal with these kinds of situations, we can write form calc or java script at the script editor.

Example code:


In the below screen shot you have the increment text field in the Hierarchy node and the out on the design view.

In the Script editor we have assigned value this.rawValue = 0.

And there is not dynamic binding for the text field Increment.


In order to obtain the increment counter dynamically for the first column of the table. We need to proceed in the following way:

Create a text field and assign its value to 0.


Event — Initialize event.

Language — Java Script.

Run At — Client.

Script :

this.rawValue = 0;

The above code initializes the value of the Increment field to “Zero”.

After initializing the value to zero, now we have to increment the counter dynamically depending on the display of the column two.

To obtain the above scenario, we need to writ the following Java script.

var a;

a = this.parent.parent.parent.parent.parent.INCREMENT.rawValue;

b = ++a;

  1. this.rawValue = b ;
  2. this.parent.parent.parent.parent.parent.INCREMENT.rawValue = b;


  1. Declaring a local variable “a’.
  2. Calling the Increment value and assigning that value to the local variable ‘a’.

    Depending on the depth of the field where we are writing the JavaScript for counter,

    We need to refer those many ‘parents’.

  1. In our case the Javascript is written at 5th level from parent i.e. Increment.
  2. As increment is assigned to zero.
  3. At first instance the value of a = 0.
  4. The value of  ‘b’ becomes 1.
  5. And later this ‘b’ value is assigned to the column 1 value. And this B value is assigned back to the Increment for using down the form.
  6. As the rows of the table increase the counter value increases as the local variable always refer to the INCREMENT value and this increment value is always being modified with updated incremented value.
  7. Hence the values of the column 2 ,3,4,5 etc display according to the incremented values.

Incase if we want to hide any of the rows in middle we can write Formcalc or Javascript to hide the rows.



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      1. What event do you use for the second script?

      2. Why doen't you use  this script(in form:ready event):

      this.rawValue = this.parent.index + 1;

      parent in this case is the table row, and +1 because the row indexes start from 0.

      Author's profile photo Varun Vadnala
      Varun Vadnala
      Blog Post Author

      1.Initialise event.

      2.The answer which you have provided will work in a table.The solution which i have provided works for both incrementing the counter in the table as well as incrementing the numericals for the side heading of the paragraphs.

      Author's profile photo Former Member
      Former Member

      Good Document....!!!!!!!

      Author's profile photo Ravinder Narsingh
      Ravinder Narsingh


      Author's profile photo Former Member
      Former Member

      Good doc.