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
Pedro Garcia GPedro Garcia G 

Create Opportunity and associate it to Contact in single statment

Hi...
I read the following article:
Creating Parent and Child Records in a Single Statement Using Foreign Keys (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_foreign_keys.htm)

In my case, I have the Contact and Opportunity info taken from a CSV. So, I'd like to insert Contact and Opportunity in one statement but the relation from them are many to may through a junction table. Opportunity Contact Role.

I appreciate any idea about how to do it. The source of data (CSV) is dynamic and it could have around 150 records.

Thanks,