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
John RadcliffeJohn Radcliffe 

Multiple Opportunity Contact Role Cloning in a New Record Type

Hello all,

I am building a flow to clone a closed-won opportunity in a pipeline for our Support team to conduct training etc. I need to bring all Opportunity Contact Roles with the clone. I figured out how to clone a single Contact Role, but most of our Opportunities have more than one, all of which we need. I've tried two methods:

First, Fast Lookup & Fast Create with sObject Collection Variables which succeeds in duplicating multiple Contact Roles but associates them with the closed-won opportunity, not the new Support Opportunity (I have the Support OpportunityID in a variable but haven't figured out how to use the Assignment element to replace the old OpportunityID with the new OpportunityID). 

Second, with Record Lookup & Record Create via a Loop. In this case, the loop succeeds in cloning the Contact Roles but only the first one - it gets hung up on the first ContactID and doesn't skip to the next one. 

What am I doing wrong? Either method is a viable solution, and any help would be greatly appreciated. 

John
Best Answer chosen by John Radcliffe
Gaurav HandooGaurav Handoo
Hi John

I believe it would help if you can post a screenshot of your flow. However, based on your explanation:
  1. For the first method, whenever you are doing a Fast Lookup, you need to run a loop on the collection created and replace the OpportunityId with the new OpportunityId (Support Opportunity), add them to another collection, exit the loop and then go with Fast Create.
  2. Second method will not work as the same is not bulkfied and would be fetching only the first Contact Role against the original opportunnity.
Hope this helps. please mark as best answer if it does.

Cheers!!
Gaurav

All Answers

Gaurav HandooGaurav Handoo
Hi John

I believe it would help if you can post a screenshot of your flow. However, based on your explanation:
  1. For the first method, whenever you are doing a Fast Lookup, you need to run a loop on the collection created and replace the OpportunityId with the new OpportunityId (Support Opportunity), add them to another collection, exit the loop and then go with Fast Create.
  2. Second method will not work as the same is not bulkfied and would be fetching only the first Contact Role against the original opportunnity.
Hope this helps. please mark as best answer if it does.

Cheers!!
Gaurav
This was selected as the best answer
John RadcliffeJohn Radcliffe
@Gaurav Handoo, thanks! I figured it out previously but your #1 was exactly what I did! Appreciate your assistance
John SadlerJohn Sadler
@John Radcliffe. Hi John ... I'm trying to do similar except I only want the Primary Contact from Contact Roles. I can't see how to get the Primary Contact from the Old Opportunity into the New. I have the Contact ID but don't understand how I identify the new opportunity in the flow.
Gaurav HandooGaurav Handoo
Hi John Sadler

Are you trying to update Primary Contact field on Opportunity or on the Contact Role?

Regards
Gaurav
John SadlerJohn Sadler
Hi Gaurav ... trying to update the Contact Role. Cheers John
Gaurav HandooGaurav Handoo
Hi John Sadler

In this case, you would need to follow the same steps as John Radcliffe did, with only one modification that instead of fetching all the Contact Roles, you need to filter the result using a filter condition of "Primary" and rest of the steps would be same.

You might not need to run a loop if you have only a single Contact Role with flag of Primary, but for future scope it is recommended that you keep the loop in place.

Hope this helps. In case of any further clarification, please feel free to contact at gaurav.handoo@gmail.com

Regards
Gaurav
John SadlerJohn Sadler
hi Gaurav. Got it sorted as I finally spotted the the option to save the new opportunity ID as a variable. So stupid of me not to realise the option was there. Once I did that, all good to go. Cheers and thanks