cancel
Showing results for 
Search instead for 
Did you mean: 

Subtotals in adobeforms

Former Member
0 Kudos

Hi,

I need to Calculate subtotals in adobeforms for quantity .Can anyone help me out with this?

My requirement is like this :

I have a field "kwmeng" for which i need to calculate the sum of kwmeng at the end of every page and need to sum up the totals of each page and print it on last page.

Can any1 provide me with the java script code to calculate the subtotal

Regards,

Nisrin.

Edited by: Nisrin Pindwarawal on Jul 1, 2008 3:30 PM

Edited by: Nisrin Pindwarawal on Jul 1, 2008 3:30 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello!

var i = 0
var p = $layout.page(ref($))
var d = 0
for i = 0 upto (page2.Table.Table2.BodyRow.all.length - 1) step 1 do
  d = $layout.page(ref(page2.Table.Table2.BodyRow<i>.POSNUM))
  if ( d == p ) then
      page2.Table.Table2.PageTotal.PLACES = page2.Table.Table2.PageTotal.PLACES + page2.Table.Table2.BodyRow<i>.PLACES
      page2.Table.Table2.PageTotal.BRGEW = page2.Table.Table2.PageTotal.BRGEW + page2.Table.Table2.BodyRow<i>.BRGEW
      page2.Table.Table2.PageTotal.NETWR = page2.Table.Table2.PageTotal.NETWR + page2.Table.Table2.BodyRow<i>.NETWR
      page2.Table.Table2.PageTotal.VAT = page2.Table.Table2.PageTotal.VAT + page2.Table.Table2.BodyRow<i>.VAT
      page2.Table.Table2.PageTotal.WRBTR = page2.Table.Table2.PageTotal.WRBTR + page2.Table.Table2.BodyRow<i>.WRBTR
  elseif ( d > p ) then
    break
  endif
endfor

Hope it will help You.

Good Luck!

Former Member
0 Kudos

Hi ,

Could u tell me how does this code work???

Because i cannot use the same code.

Regards,

Nisrin.

Former Member
0 Kudos

Table data

For each row of the table we need to find a place for the field, which will be kept current page number.

In my case it will be called "MAGRV_PAGE"

For such fields we set a script:

Event: layout: ready

this.rawValue = xfa.layout.page(this)

Subtotal

Also, as for the rows of tables, it is necessary to find a place for the field, which will be kept current page number.

In my case it will be called "Page".

For such we fields set a script:

Event: layout: ready

this.rawValue = xfa.layout.page(this)

In line with subtotals place the following script:

Event: layout: ready

var len = BodyRow.all.length; var len = BodyRow.all.length;
WRBTR.rawValue = 0; WRBTR.rawValue = 0;
VAT.rawValue = 0; VAT.rawValue = 0;
NETWR.rawValue = 0; NETWR.rawValue = 0;
LFIMG.rawValue = 0; LFIMG.rawValue = 0;


for i=0 upto len - 1 step 1 do for i = 0 upto len - 1 step 1 do
if (Page.rawValue == BodyRow<i>.MAGRV_PAGE.rawValue) then if (Page.rawValue == BodyRow <i>. MAGRV_PAGE.rawValue) then
WRBTR.rawValue = WRBTR.rawValue + BodyRow<i>.WRBTR.rawValue; WRBTR.rawValue = WRBTR.rawValue + BodyRow <i>. WRBTR.rawValue;
VAT.rawValue = VAT.rawValue + BodyRow<i>.VAT.rawValue; VAT.rawValue = VAT.rawValue + BodyRow <i>. VAT.rawValue;
NETWR.rawValue = NETWR.rawValue + BodyRow<i>.NETWR.rawValue; NETWR.rawValue = NETWR.rawValue + BodyRow <i>. NETWR.rawValue;
LFIMG.rawValue = LFIMG.rawValue + BodyRow<i>.LFIMG.rawValue; LFIMG.rawValue = LFIMG.rawValue + BodyRow <i>. LFIMG.rawValue;
endif
endfor

WRBTR, VAT, NETWR, LFIMG - are fields that you want to summarize. In my example, the names of such fields are the same as the line names of the table.

  • Value WRBTR totals: WRBTR.rawValue

  • Value WRBTR <i> row of the table: BodyRow <i>.WRBTR.rawValue

Former Member
0 Kudos

Thanks Andrei,

I solved the problem.

using xfa.layout statement.

Former Member
0 Kudos

Ok, Great to hear it.

Good Luck!

Answers (0)