2

I have a child object in a master-detail relationship. If I insert a child record with no parent ID value, but I write a BeforeInsert trigger to populate the parent ID, will Salesforce allow the record to proceed, or does the system reject the record before it reaches the trigger?

3

That should work fine. Looking at the trigger execution order, the "before" triggers execute before any system validation (unless it comes from a standard UI page, which in this case, is impossible as you can't create a record without a parent).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.