Skip to main content

I have created a junction object to establish a many-to-many relationship between 2 objects. One is a customized "role" multi-picklist in Contacts, the other is the "program name" in the custom Program object. A contact can have different (multiple) roles depending on what program the contact is related to and the contact can be related to several programs at the same time. For example, the contact can be a "contract partner" and a "research partner" for program A and, at the same time, a "collaborator" for program B. This junction "relationship" object worked in theory - the problem is that capturing these different relationships is extremely important to us, so I would need to have users identify this relationship every time they create or edit a contact, which means I need this info to be completed on the Details page of Contacts and make it a required field. However, I can only add a new relationship in the related list on the related page and thus can't make this a required field. When I create a lookup field to the relationship on the Details page of Contacts and make it required, I run into obvious issues if the contact is a completely new contact (as the contact has not been saved at that stage, so doesn't exist in the system, yet the relationship lookup field is trying to find it to reference it so it can create the requested related relationship). Any help with this would be much appreciated.

 

#Junction Object

1 risposta
  1. 21 giu 2021, 21:29

    Hi Abie,

     

    As you said, creating a junction record requires that a record exists in both Master objetcs.

    Therefore, you cannot create a master object record and its junction record at the same time, at least manually. This is not simply related to Salesforce design, but to database logic.

     

    What you could do however is create a flow that triggers at master record creation, after the record is saved, in order to create your junction record with your custom logic.

    From a user perspective, the master record and its junction record would be created at the same time.

     

    Best regards

    Guillaume

0/9000