I've been able to find a good amount of resources for copying contact roles to opportunities. This one and this one seem to be favorites, and while informative, aren't really registering with what I'm trying to do, exactly.

My goal: Create a process builder that will create a 'renewal' opportunity when stage = Closed Won. The new opportunity should copy over usual fields (amount, term, start/end dates, etc), but it should also copy over the Primary Contact from the original opportunity.

I'm having a difficult time figuring what variables I need to set in the Flow, and also how to pull the primary contact from the original opportunity in the process builder. I've attached screenshots.

Process Builder works in creating the new opp, but I can't figure out how to pull primary contact from the original opp.

I know I'm missing some elements. Could point me in the right direction of how many elements do I need/am I missing? Is my process builder at least structured right, etc?


Process Builder overview

Renwal Opp immediate action fields to update

Immediate Action for 'Add Primary Contact' enter image description here

Flow framework:

do I need more elements?

Contact ID + Opp ID variable framework:

enter image description here

enter image description here

  • the primaryContact can be found on the Opportunity's child related list OpportunityContactRoles – cropredy Jul 3 at 21:10
  • @cropredy Thank you. Am I creating a new record using that object in the flow? – Nivi Jul 3 at 21:16
  • yes, you will need to find the OCR on the original Oppo then insert a new OCR on the renewal Oppo – cropredy Jul 3 at 21:17
  • Got it. So ONE process buider and ONE flow. From a workflow perspective it would be...process builder that creates renewal upon closed won, then process builder calls on the flow? And then as far as the flow is concerned it would have how many elements (not including 'start')? 1) Get Records element (opp ID + contact ID) 2) Get records elemetn (Original Contact Role ID + 'is primary' = true, 3) Create Contact Role record on new Opp? – Nivi Jul 3 at 21:42
  • mostly right; step 2) also needs to filter by origOppoId as otherwise you'll get all OCRs for all Oppos that are primary – cropredy Jul 3 at 21:51

Here's how I would do this:

enter image description here

Two inputs:

  • oppoId (comes from Process Builder)
  • renewalOppoId (comes from Process Builder - assumes you construct the Renewal Oppo before invoking the Flow)

enter image description here

Three use cases

  • Oppo has a Primary OCR
  • Oppo has OCR but none primary
  • Oppo has no OCR

The Decision block tests for a value in the fetched oppoPrimaryOCR.Id record variable. If null, then no OCR was found for the Oppo or no primary OCR was found.

It helps to understand the gestalt of Lightning Flow when it comes to sobjects:

  • Pass in variables that are Ids of records
  • Fetch sobjects into record variables; enumerate the fields you care about in the Get Records element
  • Use assignment statements to create new variables, also of type record, to set values in the record to be inserted, either by copying values from a fetched record variable or by using a formula.
  • Use a Create Record element to insert new sobjects
  • Use consistent naming conventions.

Now the above only scratches the surface for Lightning Flow but it should help organize your thoughts.

The debug output illustrates how the blocks are built

enter image description here enter image description here enter image description here

  • thanks so much for this level of detail. I should be to go off this assuming I set up the process builder to just create a new renewal opp. Really appreciate it . – Nivi Jul 10 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.