+ Start a Discussion

formula field to loop and sum a field from a different object

Hi everyone,


I'm creating an incentive calculator and am struggling with how to do the following:


Each sales person will have an incentive plan, which I have created as a custom object. I want a field on the object that provides a running total of what business they've done, so that I can then perform the incentive calculations.

To do this I need a sum of all the business done on that accounts, I have a custom field on account that will provide the figure for each account.


Is there a way to loop through all the accounts owned by the user and return a sum of the custom field that i've created on account?


I was looking to do this as a formula field, but I couldn't see a way to query all accounts where the owner is the same user, before looping through the results and summing the custom field that I'd created.


I'm starting to think this is beyond the capability of a formula field, so if there is another way I should be doing this, I'd be greatful if someone could enlighten me.


Thanks in advance




What type of relationship do you have between the custom object and the account object? Lookup or master detail? It sounds like a roll up summary would be able to do this provided you have a master detail relationship defined for the lookup between the account object and the custom object.




it was a look up relationship


I will look into the roll up summary.