Expand my Community achievements bar.

Adding add instance into calculation

Avatar

Former Community Member

I am trying to get  fields  from  add instance/subform fields to calculate with the rest of the form fields. The problem I am having is once I "add instance" the field is no longer part of the calculation. I have tried using:

// Verify at least one instance of the midtr3a field exists.

if

(exists(location.yes900.admids.midtr3a) == 1) then

Sum(location.yes900.admids[

*].midtr3a)

endif

would appreciate any help on this.

Thanks K

3 Replies

Avatar

Level 10

I think you do not have to check for whether the field exists or not..Because when you use the "Sum" function, it will check if the field is present and if it has value or not.

You may directly try the following int he script..

Sum(location.yes900.admids[*].midtr3a

Also in your Exists function, you are checking "exists(location.yes900.admids.midtr3a)".. This will only check for the first instance of the field.

Thanks

Srini

Avatar

Former Community Member

Hi Srini,

Thanks for the response. I still cannot get this to work when I add an instance, it works for the first one, then I get an error message.

Thanks K

Avatar

Former Community Member

Ok, I got it, this is what I needed

Sum(location[

*].yes900[*].admids[*].midtr3a[*]).

Thanks K