I notice that there isn't an Orders related list that can be displayed on the Contact layout/page via the Customer Authorized By Lookup field on the Orders object. Is there a way to create a custom related list to display all orders associated with a contact via that lookup field? Possibly via a Visualforce page or Lightning component? I imagine I can create a separate contact lookup field on the orders object, but I'd prefer not to do that if I don't have to.
Ah yes, the OOTB lookup fields on Order
that reference Contact
are not supported by related lists because those relationship names don't exist in the schema:
BilltoContactId
CustomerAuthorizedById
ShiptoContactId
As you can see in the example, the OOTB Contact -> Quote relationship exists but not for the aforementioned fields. This limitation affects (hilariously) Contact merge as the lookup fields in the child Orders of the losing Contact won't be updated (because the Order children can't be found). See Known Issue
In our org, I wrote a small VF page/controller that fetched the Orders whose CustomerAuthorizedById
matched the standard controller's Contact.Id
. As lookup fields are indexed, performance was fine.
You do not need to create a shadow XXXcontactId__c
field on order unless you want to use OOTB related lists on your standard layout. Such shadow field would need to be maintained by trigger, WFR, or PB. Such shadow field would be changed by Contact Merge (while the OOTB fields will be broken unless you write apex to deal with this)