function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jonathan Gonzalez 13Jonathan Gonzalez 13 

Child Object with two opctional Master-Detail Relationship

Hi,
I need to create a Custom Object (Time__c) ideally with two Master-Detail Relationship: with case and with opportunity and only fill one relathionship each time: I will hace Time__c record related to case only and others related to opportunity only. I want to use MAster-Detail Relationship because i need to use several Roll_up fields.
I can create the object with the two master-Detail Relationships, but i need to relate the record to a case and to an opportunity.
Any workaround ?
I think about create two similar objects (Time1 and Time2) each one with a MAster-Detail Relationship, but maybe i will have problems reporting about them together.
GovindarajGovindaraj
Hi Jonathan,

Opportunity <--> Time <--> Case

If above relationship created with two M-D relationship then Time__c will become an Junction object and Many-to-Many created between two objects.

Create a dummy Opportunity and choose that when Case alone exist. Similar way, create a dummy Case and choose that when Opportunity alone exist.

Thanks,
Govindaraj.S
Jonathan Gonzalez 13Jonathan Gonzalez 13
Hi Govindaraj,
The Relationship is one of two :
- Opportunity <-- Time
- Case <-- Time
For example, in the Time object i have two fields Case and Opportunity. But i only need one field with value, case or opportunity, but not the two. With Master Detail, the system require fill the two fields for saving the record.
GovindarajGovindaraj
Hi Jonathan,

What i'm trying to say is,

Create a dummy record in Opportunity and Case.
So, If Time__c has only Opportunity then fill it and for Case put dummy created record viceversa.

Thanks,
Govindaraj.S
Jonathan Gonzalez 13Jonathan Gonzalez 13
Thanks Govindaraj,

Yes this is an workarount therefore not ideal.