cancel
Showing results for 
Search instead for 
Did you mean: 

Total table column with groups

Former Member
0 Kudos

Hi All,

I have added a piece of javascript to my form to total a column within a table on my form, before I added grouping within the table it was working correctly but now it only seems to total the first group.

Here is the code

var fields = xfa.resolveNodes("data.Body_subset.List_subform.IM_LIST.DATA.GROUP.DATA[*].ZWERT");

var total = 0;

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

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

}

this.rawValue = total;

I have tried debugging from the Adobe Reader but after following instructions to install the debugger it stopped my Reader working so I have had to give up and re-install. Is there any javascript guys who can point me in the right direction ?

Accepted Solutions (1)

Accepted Solutions (1)

OttoGold
Active Contributor
0 Kudos

Hello,

first: SAP recommend (and I recommend) not to script in the form if that is not necessary. And I think this time it is not necessary, right? Why don´t you sum your column in backend and only mark the sum rows with some flag and then handle marked rows (sums) the different way in the form (like use bold font or anything you want).

second: maybe the change you´ve made was change of the structure, right? Like add/ remove subform (add if you say "groupping"). That means that the path in the script is no longer relevant? Check that.

third: use app.alert(yourfield.rawValue) to debug your scripts (gives a message box, try that), only use this alert without the plus mark (I cannot write it, because it disturbs this pages internal coding).

Hope this helps, Otto

Former Member
0 Kudos

Thanks for the response but I guess I need to make it clearer , it is an offline scenario so there is no way of doing the calculation in the backend as the user is entering quantities offline. The second suggestion was a problem but I fixed the script to reference the node correctly as it started to error once I introduced grouping so that rules that one out. I will try the third suggestion as unless I can see the values at run time I have no chance to see that I am looping correctly.

Former Member
0 Kudos

Fixed the problem, the script should read

var oFields = xfa.resolveNodes("data.Body_subset.List_subform.IM_LIST.DATA[].GROUP.DATA[].ZWERT");

not

var oFields = xfa.resolveNodes("data.Body_subset.List_subform.IM_LIST.DATA.GROUP.DATA[*].ZWERT");

this gives me a total for all entries not just first group

Former Member
0 Kudos

I like your scripting! It is exactly the offline scenarios of remote clients that make it a necessity. If you perhaps have some Adobe Java Scripting example links, please post them here. Thank you, Adrian

Answers (1)

Answers (1)

OttoGold
Active Contributor
0 Kudos