Expand my Community achievements bar.

Sum one particular field in numerous subforms

Avatar

Level 3

Hello,

I have a field named DurFramesDurationMin within a repeating subform. Here is the full path: employees.P1.ListGroup.Add_subform.DurFramesDurationMin

I would like to have a field total the rawValue of all instances of this field. I have tried the following:

(FormCalc, client)

$.rawValue = sum(employees.P1.ShotListGroup.AddShot_subform[*].DurFramesDuration2);

(Javascript, client)

var fields = xfa.resolveNodes("employees.P1.ListGroup.Add_subform[*].DurFramesDurationMin");
var total = 0;

for (var i=0; i <= fields.length-1; i++) {
    total = total + fields.item(i).rawValue;
    }
    this.rawValue = total;

The total field is on a master page so that it shows you current total at all times (I will set this to Global binding I assume to make this work).

Thanks for any and all help!

9 Replies

Avatar

Level 6

Hi,

I've made example form with sum on master page. maybe it can help you to solve problem.

BR,

Paul Butenko

Avatar

Level 3

Paul,

Thanks for the response. On my form it does total the first field but does not total the instances of that field. Should I reference the instance manager in the same script?

Avatar

Level 6

Could you post your form? I'll check it.

BR,

Paul Butenko

Avatar

Level 3

Here you go and thanks. totalminutes should total all data in every instance of DurFramesDuration2...

Again, it will see the data for the first one but not the second...there is no calculation going on for the others...

BTW, I deleted much of the content to make it easier - it shouldn't have broken anything though.

Avatar

Level 6

Hi,

Main problem is that you were trying to take wrong subform - employees.P1.ShotListGroup[*].AddShot_subform[*] instead of employees.P1.ShotListGroup.AddShot_subform[*].

On layout ready event of totalminus i wrote function which calculates total.

See attach.

BR

Avatar

Level 3

Thanks for the response - day 5 of waiting for the form to become available to view...

Avatar

Level 6

I can send it to you, just post your email.

BR

Avatar

Level 3

ebuxton@gmail.com

Thanks again...