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

Delete Opportunity when child object Grand total is 0?
Hi,
I have a custom object as child to opportunity object.
I want to delete opportuntity every night, when all the child records for it is 0.
I want to write a batch apex(schedulable), which deletes all such records at 12:00 in the night.
So lets say,
If an opportunity has 2 child records, and the Grand Total value on both child records is 0, I want to delete the opportunity along with its child record.
It should only happen, when both child records value is 0. In case where the child record value is there for one of the childs.. it shouldnt get deleted
I have a custom object as child to opportunity object.
I want to delete opportuntity every night, when all the child records for it is 0.
I want to write a batch apex(schedulable), which deletes all such records at 12:00 in the night.
So lets say,
If an opportunity has 2 child records, and the Grand Total value on both child records is 0, I want to delete the opportunity along with its child record.
It should only happen, when both child records value is 0. In case where the child record value is there for one of the childs.. it shouldnt get deleted
is Grand Total is a custom field on child object ? and when in all child records this field value is 0, in that case parent opportunity should be deleted. Correct me if I am wrong.

Yes.. The child name is "PI" . In cases where all PI's are 0. i want the opportunity to be deleted