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

Primary Campaign Source on Opportunities created through Apex

When you start off with a Contact that's associated with one or more campaigns, when you create a new Opportunity from the related list on the Contact the Campagin Influence is set on the Opportunity, and one of the campaign members is chosen as the Primary Campaign Source. I have Apex code that creates the Opportunity and links in the Opportunity Contact Role. When I create the Opportunity through the code, the Primary Campaign Source is NOT set. I know you can set the CampaignId on the Opportunity and that will make the Campaign the Primary Campaign Source, but it will not make the Campaign Member the Primary. I know there's not really a way through code to set the Primary Source on the campaign member, but does anyone know why it does not set a Primary Source when I don't set the CampaignId on the Opportunity creation?
Thanks - that's the API documentation but it doesn't answer my question about the Primary Campaign Source.