 Former Member

Hello everyone,

I have the following requirement:

If i have 12 items in my i_item table:

Page 1 --> 8 items fit

calculate and display subtotal of field amount(WRBTR) of the 8 items at end of page 1

Page 2 --> remaining 4items fit

display the subtotal displayed on the on the previous page as first record of page

display remaining 4 items

calculate and display subtotal of field amount(WRBTR) of these 4 items at end of page 2

In last page calculate and display grand total based on the subtotals

In my table i_item (DATA section) i added a footer section and placed the code SUM(I_ITEM.DATA[].WRBTR[]) in the subtotal field, but it gave the grand total.

As per SDN i changed the code to SUM(WRBTR[]) but nothing is displayed on the form. I also tried SUM(DATA[].WRBTR[*]) and i obtained the valu

Settings used: Formcalc , Client, Calculate, Calculation Script

i also tried the following two Javascript code with the following settings

Javascript, Client, Events with Scripts, Calculation Script

in the footer row and i obtained nothing on screen

first code used:

var fields = xfa.layout.pageContent(0 , "field", 0);

var total = 0;

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

if (fields.item(i).name == "WRBTR") {

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

}

}

this.rawValue = total;

second code used:

var fields = xfa.layout.pageContent(xfa.layout.page(this)-1, "field", 0);

var total = 0;

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

{

if (fields.item(i).name == "WRBTR")

{

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

}

}

this.rawValue = total;

kindly provide help.

thanks&regards;

10|10000 characters needed characters exceeded

### Related questions Former Member
Posted on Jun 04, 2009 at 06:58 AM

Hi Devi,

Try with this code.

1. For subtotals:

• Show: Eventswith script, language: Javascript, Run At: Clinet.

var fields = xfa.layout.pageContent(xfa.layout.page(this)-1, "field", 0);

var total = 0;

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

if (fields.item(i).name == "NETPR") {

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

}

}

this.rawValue = total;

2. For Grand total:

• Show: Eventswith script, language: FormCalc, Run At: Clinet.

sum(data.Subform1.T_VBAP.Group1.DATA[].NETPR[])

Regards,

Raju.

10|10000 characters needed characters exceeded
• Former Member

Hello Raju,

I tried it, but its not working. It may be perhaps the way my Hierarchy is built.

I have 2 master pages

and 2 reference page

in each reference page i have my item table

Could you please tell me how to reference name of the field WRBTR in the table?

Perhaps it is this that is causing the issue as i am obtaining no result.

Many thanks

• Former Member
Posted on Feb 16, 2016 at 02:27 PM

Hello,

Could you please help me implement this solution? I have the same request and I implemented your proposal, but it only works for me when there only one item per page. For pages with many items, the value of the subtotal field is always 0.

Best regards,

Alexandra