Can child records with a self-lookup field be inserted in a single job?


Can child records with a populated self-lookup field (i.e., a ParentId field pointing to the same sObject type for the Account object) be inserted in a single job, especially when the after insert trigger logic is dependent on whether the self-lookup field is populated?


It is impossible to insert child records with self-referential parent lookup fields pre-populated since the target parent IDs may not be known in advance.

The plugin consistently performs two actions for self-referenced objects:

  1. Inserts all records with the self-reference field set to null.
  2. Updates the self-reference fields with the already existing parent values.
Last updated on 18th Apr 2024