OK....this is likely very simple, but I'm struggling.
I have a Registration object that includes an attribute named, TotalPaid. It's numeric and specified to be calculated. It also has a MyPayments attribute of the type Payment (child of Registration).
I have a Payment object that has an AmountPaid numeric attribute. There can be multiple Payment instances for a specific Registration.
I'd like to be able to sum up all of the Payment.AmountPaid for any particular Registration and have that number appear in Registration.TotalPaid.
Thought I had it working, but it seems to be summing ALL Payment instances, not just the ones associated with a specific Registration.
Thought I could do the following as a rule in Registration:
IF EXISTS Payment WHERE (Payment IN ThisRegistration.MyPayments)
Then TotalPaid = SUM (ThisRegistration.MyPayments.TotalPaid)
Else TotalPaid = 0
Obviously, I'm getting all Payment instances into Context.
summing child objects
-
- Posts: 51
- Joined: Wed Mar 29, 2006 12:48 pm
- Location: Pennsylvania, USA
- Contact:
-
- Posts: 595
- Joined: Sun Apr 24, 2005 2:22 am
- Contact:
Tom,
Your rule should look like this:
Registration.TotalPaid = SUM Payment.AmountPaid WHERE (Payment IN Registration.MyPayments)
You do not need the 'If' and 'Else' bits because the SUM will automatically return zero if there are no payments for the registration. Also, you do not need the 'This' prefix since there will be only once instance of Registration in the context when the rule is executed so the system will automatically recognize it.
Your rule should look like this:
Registration.TotalPaid = SUM Payment.AmountPaid WHERE (Payment IN Registration.MyPayments)
You do not need the 'If' and 'Else' bits because the SUM will automatically return zero if there are no payments for the registration. Also, you do not need the 'This' prefix since there will be only once instance of Registration in the context when the rule is executed so the system will automatically recognize it.
Aware IM Support Team