Increment of Numeric Values using Javascript in SAP Adobe forms.
We might come across certain situations where we need to increment the numeric counter
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:
A
C
E
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.
Syntax:
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;
Explanation:
Depending on the depth of the field where we are writing the JavaScript for counter,
We need to refer those many 'parents'.
Incase if we want to hide any of the rows in middle we can write Formcalc or Javascript to hide the rows.
Regards,
Varun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
9 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |