cancel
Showing results for 
Search instead for 
Did you mean: 

tableCalcs method Sum does not work

glio_ad
Active Participant
0 Kudos

Hi all.

I am newcomer in the ADOBE forms world and I am facing the following issue (although I 've been reading posts in SDN and respective manuals for over 3 days)

My form's hierarchy is:

(xfa.form.)

-data

-MasterPageSet1 (Page Set)

---Page1 (Master)

--ContentArea

--HeaderData (positioned subform with various elements)

--FooterData (positioned subform with various elements)

---MainWindow (Flowed subform)

--t_subf (Flowed subform)

--Table (table which will show data from respective interface table)

--Header

--RowData (actual line items)

--PageSum (table footer)

Both RowData and PageSum have a decimal field named "DMBTR_S"

At the end of every page, in the PageSum-DMBTR_S field, I want to sum the page's RowData[*]-DMBTR_S data to produce a "carry Fwd" for the next page.

Looking through SDN and LiveCycle designer help, I have tried both using JavaScript and using the tableCalcs but with no luck

Given that I am a newbie in both ADOBE forms and JS, I assume that I am missing some details.

So, I suppose that the tableCalcs (with the parameters for the current page) can help me the most, without needing me writing JS.

However, I do not understan at which level in the aforementioned hierarchy should I insert the tableCalcs.

I tried inserting it under MainWindow subform and renamed the unnamed subform to "tcalc"

Then, I set PageSum-DMBTR_S field to Calculated-ReadOnly, with Normal Bindin, and I write in the calculate event:

if ( xfa.layout.page(this) == xfa.layout.pageCount())

{

//I copy the header's amount as the final total 😛

this.rawValue = t_subf.TOT.rawValue;

}

else

{

//calculate the cummulative from age 0 to current

this.rawValue = MainWindow.tcalc.tableCalcs.Sum("Table.RowData[*].DMBTR_S",0, xfa.layout.absPage(this)-1);

}

When I preview the PDF inside the Form Builder (trans: SFP), PDF is generated successfully, without any warnings/errors at all.

What am I missing here?

Thank you in advance,

George

Accepted Solutions (1)

Accepted Solutions (1)

OttoGold
Active Contributor
0 Kudos

Hello,

you have various options (I will not mention the table calcs in my list ebcause i cannot use it or i didn´t get what you mean).

a) you can do that in backend - if you know how the items will be distributed (like 15 items per page or 1 items group on every page etc.), you can count the subtotals in backend and send it to the form pre-calculated

b) you can loop at the all fields/ components of the form, for every field test the properties and if it is your line, you can add a page number into some secret field. After this numbering you can loop at the list of lines and count sums manually for every group (page number)

c) or some other

I hope you have found these two scripting guides:

http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics/lc_designer_scripting_ba...

http://help.adobe.com/en_US/livecycle/es/FormCalc.pdf

Regards Otto

glio_ad
Active Participant
0 Kudos

Hello Otto and thanks for the reply.

a) I could indeed do it in the backend but that means that I have to hardocde the max number of line items per page. I always prefer to decouple application logic (the printing program) from the presentation medium ( the form). However, that would be me utmost way of doing it, as the time is against me...

b) I understand what you mean, but I don't have a single clue how to do it with Javascript Pretty smart, but I would prefer the (a) approach, as I can code it way much faster with ABAP in the printing program

c) another solution may be the tableCalcs. This "collection" of objects/methods has already implemented a Sum method which seems to do exactly what I need. I have read both the PDF documents you mention but unfortunately I haven't managed yet to make it work in a... stylish (!!!) way.

In page 103, the "lc_designer_scripting_basics.pdf" offers a JS snippet to "calculate the sum of repeating fields". I have alse tried this approach but it seems that the statement var fields = xfa.resolveNodes("RowData[].DMBTR_S[]"); doesn't work at all. I have included it in a "try-finally" block and it fails...

Anyway, I will keep trying and come back to the post. If you have done anything similar I would appreciate it if you could post any relevant JS code snippet.

Thanks again,

George

OttoGold
Active Contributor
0 Kudos
var fields = xfa.resolveNodes("RowData[*].DMBTR_S[*]"); 

I don´t have time to inspect your form structure but in any form the code is wrong. You need to understand how it works when you address any form component/ field. You should use the same/ similar "address string" as you can find in the binding of the field you want to sum, I hope that gives a clue how to start.

By the way, you can use relative addressing using "this" pointer and "parent" pointer. For example when you place your script on the subform level, you can use this to start the address with the form you have placed the script on and using like this.field1 you can access the field1 in that subform.

I can recommend you to check for some sample forms: check the Adobe.com page, you should be able to find some dummy forms which ARE working.

I am sorry I cannot solve this for you but I hope I have mentioned few clues to start from, regards Otto

glio_ad
Active Participant
0 Kudos

Hi Otto.

I have just seen your reply.

In fact, I have no experience in Javascript and unfortunately I don't have time at the moment to deal more with the issue, so, I will do it "quick and dirty" meaning, I will calculate the page totals in the printing program using ABAP and then just handle the totals in the form.

I was almost sure that the problem is the referencing of the repeating table fields, and that's the reason why I also posted my document's hierarchy, so that hopefully someone could quickly point me out the error.

I will also check in adobe.com for examples, as you mention.

Thank you once more,

George

glio_ad
Active Participant
0 Kudos

Hi again to all.

Unfortunately, I didn't have the time to study JS and solve the referencing problem, so I did it the "dirty" way, meaning, I created a routine in my program that according to the number of the line items and the maximum number of rows that the actual form can hold, it appends the "carry from/to" lines in the items internal table that is passed to the form's interface. So, the form has only to display the items and doesn't have to cope with page sums etc.

I don't like this approach but the time was pressing me. If anyone can post the "correct" way of doing it, I will be mostly pleased to learn it.

Thanx again to all.

Answers (0)