Creating Opportunity Contact Roles Based on a Contact Lookup Field


Salesforce Flows are a great way to ensure that your records are created properly and with the correct record relationships.


In our example, we have a custom Contact lookup field on Opportunity records who represents that primary Contact for that Opportunity. When this field was populated with a Contact, it still did not “officially” relate that Contact to the Opportunity in the standard Salesforce way, which is by creating the Opportunity Contact Role relationship. In this example, we discuss how to create the Opportunity Contact Role when the “Contact” lookup field is populated.


We will use both flow and process builder to launch the flow.


To begin, ensure that your Opportunity object has a lookup to the Contact object.



We created an autolaunched flow, which can be triggered from process builder, and its elements are actually very simple. You only need a Create Records element.



The custom variables we created here are {!ContactID} and {!OpportunityID}. These values will be populated by process builder as it is triggering the flow. These variables are both Text variables and are marked as “Available for Input”.




You will create a record for the Opportunity Contact Role object, and will set its Contact ID and its Opportunity ID to equal the variables that were created.



Now you can save the flow and activate the flow.


Next, we use process builder to trigger the flow. In your Process Builder for the Opportunity object, first a check will be run on the Contact lookup field to see if it is not null. Ensure that you mark the criteria to only run the action when specified changes are made to the record. This will keep the flow from unnecessarily firing when it does not need to.




For the action, choose Launch a Flow. Then select the flow that you created. Here, you will map the ContactID and OpportunityID flow variables to the Opportunity’s Contact lookup field, and its Opportunity ID.



You can now save and activate the process builder. Now, whenever the Contact lookup field on the Opportunity is populated, the corresponding Contact Role record will be created.


203.247.9428

New York, NY 10014

© 2017-2020 by Admin Within LLC