Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Calculate Group Totals

Avatar

Level 1

Hello,

i'm working with calculations in dynamic tables. At the moment i achieved page wise totals and grad totals.

That works the way it suppose to. No i'm facing the problem that i need to calculate group totals by a specific

field in my table.

My table/form should look like this.

Page1:

ID Date Amount

1  ......   10

Group total 10

2  ......   10

2  ......   30

2  ......   30

Group total 70

Page total  80

Page2:

ID Date Amount

3  ......   10

3  ......   30

Group total 40

4  ......   10

4  ......   30

Group total 40

Page total  80

Grand total 160

Is it possible to realize this by script?

Maybe someone of you can help me a little or give me a hint. Thanks in advance!

10 Replies

Avatar

Level 7

Hi Michael,

Could you post your form?

Avatar

Level 1

This is my form. Data in the form is from a SAP System.

Avatar

Level 7

Hi Michael,

Something like this should work for you:

this.rawValue = sum (form1.#subform[0].group1[*].rawValue)

The script is formcalc. All you need to do is change the path to match your form. I've posted a sample for you.

Avatar

Level 1

Hi djaknow,

first of all thank you for your reply. But i tried it already this way.

Maybe you misunderstood me, i need sums of groups, by a specific attribute. In this case ID. I attached a file like it should appear, but still the group sums dosen't work. I achieved the groups by conditional breaks in data row.

Avatar

Level 7

Are you populating a dynamic table from an outside datasource? Maybe this would work better for you:

var jpt = xfa.form.form1.subformNameHere.resolveNodes("subformNameHere[*]");

var sum = 0.0;
for (i = 0; i < jpt.length; i++) sum += jpt.item(i).resolveNode("groupNameHere").rawValue;

this.rawValue = sum;

This is javascript.

Avatar

Level 1

Hi,

yes the data is from outside. I get the data from a SAP System. I'm working with forms within SAP, so called SAP Interactive Forms by Adobe.

I tried it with different scripts, the problem i have to solve is, that in every row is allways the same value. I cant realize a sum by ID, i almost think that this is not possible, because it is a table and you cant calculate different in different rows. Even when i put in IF clause into the calculations, the value will be everytime the same, because of loop of the table.

Hope you understand me!

Avatar

Level 7

I'm not familiar with SAP so I can't help you there. Even so, I would think that each cell in the table would still have it's own unique name whether it's assigned by you or generated by the form as the dynamic fields are created.

Avatar

Level 1

Yes each row has an unique name. But during design time, i have just one cell to implement script.

Avatar

Level 7

Can you run a script server side, possibly within the workflow (I'm assuming the form is being generated by a workflow, please correct me if I'm wrong) to get your totals before the form is generated?

Avatar

Level 1

Hi,

sorry that i answer so late.

Thanks for your idea, i almost had the same one. But till now i didn't have the possibility to check it.

I will let you know if its work.