on ‎2021 Jun 25 2:52 PM
Hi everyone,
How can I count rows in table in SFP using JavaScript code? I am using xfa.resolveNodes function as I've seen somewhere else, but it only returns value "1", even if the table has much more rows.


I know that I can do this by counting rows in interface, but I wanted to do this using JavaScript directly on form's layout. Did I choose wrong event or something? Or maybe I am using wrong path in resolveNodes?
I'd be grateful for all help.
Request clarification before answering.
Hi Barlomiej,
I have simulated your requirement. Below is the interface, as you can see I have a table "IT_MARA" whose count will be displayed on the adobe form.

Below is the code to find out the count and assign the count to the "TextField1". The code is written using java script in "Initialization" Event of the text box in AdobeForm
xfa.resolveNode("TextField1").rawValue = xfa.resolveNodes("$record.IT_MARA.DATA[*]").length;
Below is the output. I am passing 30 lines to the table IT_MARA.

Alternate Approach:
As you have already added the field "GV_ITEM_COUNT" to the interface, you can also count the line of the table and assign to GV_ITEM_COUNT in interface itself using ABAP instead of doing it with JavScript.
Hope this answers your questions.
Thanks,
Gourab
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your answer. I have made a mistake in my code, it looked like this:
this.rawValue = xfa.resolveNodes("$record.IT_PO_ITEMS[*]").length;And it should look like this:
this.rawValue = xfa.resolveNodes("$record.IT_PO_ITEMS.DATA[*]").length;I completely forgot that I am trying to get size of DATA inside IT_PO_ITEMS, not the IT_PO_ITEMS itself... 🙂
Anyway, thank you again for your help!
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.