You need to sign in to do that
Don't have an account?
Rocky.4Q
Master-Detail Relationship one-to-one
I need the behaviors of the Master-Detail relationship (cascading deletes) but I only want to a one-to-one relationship. What the best way to go about this?
Do you need to restrict user behaviour in some way? Master detail can be used in a 1-1 way simply by only creating one child object. If you need to ensure that only one detail is attached, there's a variety of ways to achieve this. One would be to have a validation rule that errors if the roll up summary (count) of detail records is > 1. Aside from that you could have a trigger that sets the detail record id into the master and error if this is already populated.
All Answers
Do you need to restrict user behaviour in some way? Master detail can be used in a 1-1 way simply by only creating one child object. If you need to ensure that only one detail is attached, there's a variety of ways to achieve this. One would be to have a validation rule that errors if the roll up summary (count) of detail records is > 1. Aside from that you could have a trigger that sets the detail record id into the master and error if this is already populated.
I assumed so, but I wanted to make sure I wasn't missing something. I programmatically create the the relationship, so removing the "new" button from the related list and ensuring that another isn't created in the trigger does the job. Thank You. I really just want to enforce the master-detail cascading deletion, an d this seems to work.