Find your content:

Search form

You are here

Delete of former parent in trigger causes workflow failure on child


I have a Lookup relationship from Contact to a custom object, and an "after update" trigger on Contact that deletes any of those related objects that no longer have children. There is a workflow rule on Contact that references fields from the parent object. I find that when I change the related object - i.e., reparent the Contact - and the old parent is deleted by the trigger, the save fails with the following error message:

The formula in the "TestRelatedWorkflow" rule or process is invalid due to the following: The record you attempted to access has been deleted

It seems to me that the workflow rule should be referencing the new (updated) parent object and its fields, not the old (deleted) parent. I read the trigger order of execution document carefully, and it seems to indicate that workflow rules should be evaluated after all triggers. Am I missing something? Is there a sensible workaround?

Update: this is now filed as case 09012899

Attribution to: Jeff Trull

Possible Suggestion/Solution #1

The workflows fire after the triggers, but if there are any field updates that do change the values the triggers are fired again. So the triggers could run before and after workflows. Maybe use some static variable to determine if this is the first time or the second time the triggers fire.

Attribution to: Andres Perez

Possible Suggestion/Solution #2

As of Winter 14 (or perhaps Spring or Summer 13) this issue is no longer reproducible and thus the question is moot.

Attribution to: Jeff Trull
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content