Expand my Community achievements bar.

SOLVED

Getting the sum of variable rows (rows number is unknown)

Avatar

Level 2

Dear All,

I need to create a script with the option for addidional raws (Dezimalfelde2 +Dezimalfelde3+..... ) the total sum should include all future raws…

How can I create it? Please see above the below javascript…I tried to write (Dezimalfelde2[*]) just to indicate all fute rows but its not working!

plz help ?

1.png

1 Accepted Solution

Avatar

Correct answer by
Level 10

Moin,

the accessor is placed at the wrong place.

There is only one "Dezimalfeld2" in each row so you don't need the [*] accessor here.

But the row "detail" is repeating, so here is the place you should use it.

var total = 0;

var fields = xfa.resolveNodes("Tabelle4.detail[*].Dezimalfeld2");

for (var i = 0; i < fields.length; i += 1) {

    total += parseInt(fields.item(i).rawValue);

}

this.rawValue = total;

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Moin,

the accessor is placed at the wrong place.

There is only one "Dezimalfeld2" in each row so you don't need the [*] accessor here.

But the row "detail" is repeating, so here is the place you should use it.

var total = 0;

var fields = xfa.resolveNodes("Tabelle4.detail[*].Dezimalfeld2");

for (var i = 0; i < fields.length; i += 1) {

    total += parseInt(fields.item(i).rawValue);

}

this.rawValue = total;

Avatar

Level 2

Thank you sooooooooooooooooooooooooooo Much!

it works perfect