function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JayseJayse 

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

 

Jayson

kcpluspluskcplusplus

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.

 

--KC

JayseJayse

it was a look up relationship

 

I will look into the roll up summary.