I have a design question that I wanted to run past you guys. I’m not sure what I’m doing is a SF best practice, and could use some feedback.
In my sf, opportunities have a start date and an end date.
On the account, I want to get the # of opportunities that are closed won, and that have an end date greater than today for an account. So when the account is viewed, this will give me the right # at all times. Ok- so I see 2 things- when the opp's 'start date' >= today, the # field needs to increment on the account, then when today > the end date, the account needs to decrement.
Increment: Opportunity - after insert trigger. When the opp is edited, and stage = c/w and start date >= today and end date < today, do a soql and update the # on the account.
On the opp, do a time based workflow. On the opp 'end date,' update a random field on the account. Then on the account run a before update account trigger that does a soql and updates the field.
Is this implementation ok? I don't like the idea that there are a bunch of deferred field updates that are floating around out there. Also, if I’m updating 10 opportunities with the same account, it seems wasteful. Maybe I should create a helper field on the opportunity?