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

Adding Campaign to an Opportunity

I want to add a campaign to an opportunity and not have it be the  Primary Campaign source.  How do I do that?  I tried this in VB.NET


Dim oSFOpportunity As sForce.Opportunity = oQR.records(0)

            oSFOpportunity.CampaignId = SCampaignID

            oSFOpportunity.Campaign_Primary__c = Nothing

I see the new campaign linked to the Opportunity, but marked as Primary.  What should I do?


i hope the field Campaign_Primary__c is a look up to Campaign. you just have to do the following.


Dim oSFOpportunity As sForce.Opportunity = oQR.records(0)
            oSFOpportunity.CampaignId = Nothing
            oSFOpportunity.Campaign_Primary__c = SCampaignID

 Opposite what you have actually done. Let me know if it does not solve your problem.


Thanks so much for your advice.  I tried the code as you suggested, however I do not see the campaign when I select the opportunity.  I want to do in code what can be done in SF itself.  I want to select an opportunity and then add a campaign influence which is not primary.




Can you please tell me your requirement in brief. Also can you please let me know the data type of Campaign_Primary__c

and reason why you created it when you already have a standard campaign field on opportunity.