Can child records with a self-lookup field be inserted in a single job?
Question:
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?
Answer:
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:
- Inserts all records with the self-reference field set to null.
- Updates the self-reference fields with the already existing parent values.