You need to sign in to do that
Don't have an account?

How to update a parent sobject field when a child field = today
- So I have parent sObject insurance Policy and detail sObject Receipt.
- A policy status is dependant on the current Receipt status. (i.e. current receipt status = expired then policy status = expired, or current receipt status = paid then policy status = paid)
- Receipt has a formula field IsCurrent which calculates YES or NO if today is between the receipt start and end date. So one of the N Policy receipts will be the current one.
- The first approach was with a lookup field to the Receipt in Policy; and then update this Policy field from a trigger on Receipt when it was inserted or updated. This worked but doesn't consider the fact of time passing by, and there will be a time when the current Receipt is not current anymore.
- Second approach was with a formula field on Policy, so that it calculates which Receipt was the current one. But no SOQL on Formulas is allowed.
- Third approach was with a Workflow on Receipt and a Time-dependant trigger fired on 0 Hours After Receipt.StartDate. But this doesn't allow me to update the Policy field.
Can somebody help me find out an effective way to accomplish this?
I am also in the same situation.
But we are using batch process which will be scheduled to update the field based on the date field .
Try it .
Suree thans for the reply. I'm already trying that way, but since is the first time I get into scheduled apex I'm making progress very slowly.
Do you know if the best approach is through batch process or could it be done just through a regular scheduled class?