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
KitiKiti 

Patterns for implementing many-to-many relationships between SF Objects

I'm new to SF developement and have not been able to find a recommended 'best-practice' for representing many-to-many relationships between objects.

 

I've designed the following entities:

 

i)   Invoice - Representing a demand for payment - which may be payed through multiple payments

ii)  Payment - Representing an actual payment (which may be allocating 'across' multiple invoices.

iii) PaymentAllocation - Essentially a relationship container - associating a paymentId to an invoiceId

 

The later would be populated in Apex space and is my attempt to repersent this sort of many-to-many relationship which does not appear to come out of the box.

 

I was hoping that others would advise as to the recommended 'SalesForce' way of accomplishing this sort of relationship/behaviour?

 

I appreciate the feedback.

Thanks,

 

Raf

 

werewolfwerewolf
The most common way to do that is to create a custom object which contains master-detail relationships to both sides -- so for example you might have an AccountInvoice object which has a master-detail to both Account and Invoice.