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
HarryBHarryB 

How to create an Opportunity Partner via the API?

Hi there,
 
how is one supposed to create an "OpportunityPartner" object using the API? According to the Apex Explorer this object is only query-able and retrieve-able, so basically a readonly construction.
 
So, is creating/updating a new OpportunityPlan plain impossible is there just a trick that I'm unaware of? 
 
Cheers,
Harry
Best Answer chosen by Admin (Salesforce Developers) 
gurumikegurumike

The way to create an OpportunityPartner is actually through creating another type of object.  You need to create a "Partner" object and fill in the OpportunityId, AccountToId, and IsPrimary fields.  The Role field is not required, but you may wish to fill that in as well.  Leave the AccountFromId and ReversePartnerId fields empty (null).

 

AccountPartner records are created in a similar fashion, where you leave the OpportunityId null and instead fill in the AccountFromId.  Salesforce determines which type of record to create (OpportunityPartner or AccountPartner) based on which fields are filled in.  It will give you an error if you attempt to fill in both the OpportunityId and the AccountFromId fields.

 

Why they chose to do it this way isn't clear.  There are a few other places in the schema that may act similarly, so if you find yourself unable to create a particular type of object, you can often accomplish what you want by creating another type of object (e.g. you can create a completed Task, but you can't directly create an ActivityHistory record).

All Answers

cmarz_1cmarz_1
So is there no way to do this?  I have a bunch I wanted to import using the Data Loader but it doesn't look possible.  Drats!
gurumikegurumike

The way to create an OpportunityPartner is actually through creating another type of object.  You need to create a "Partner" object and fill in the OpportunityId, AccountToId, and IsPrimary fields.  The Role field is not required, but you may wish to fill that in as well.  Leave the AccountFromId and ReversePartnerId fields empty (null).

 

AccountPartner records are created in a similar fashion, where you leave the OpportunityId null and instead fill in the AccountFromId.  Salesforce determines which type of record to create (OpportunityPartner or AccountPartner) based on which fields are filled in.  It will give you an error if you attempt to fill in both the OpportunityId and the AccountFromId fields.

 

Why they chose to do it this way isn't clear.  There are a few other places in the schema that may act similarly, so if you find yourself unable to create a particular type of object, you can often accomplish what you want by creating another type of object (e.g. you can create a completed Task, but you can't directly create an ActivityHistory record).

This was selected as the best answer
cmarz_1cmarz_1
Thanks so much - that worked
Allie GoldAllie Gold
I want to reference a field on the Account object when adding Role to the Partner record on the Opportunity.
So far, this works:

 Current

However, I can't figure out the formula for the value that will reference a field on the Account object ("{!PartnerID}") and fill this Role with the field value on the referencable field:
User-added image

The field on the partner account object is SFCCLtngPtr__Partner_Type__c

Any ideas? I've tried "{!OpportunityID.PartnerID.SFCCLtngPtr__Partner_Type__c}" as the formula, but when I save my flow an error appears: 
Error 
Allie GoldAllie Gold
I actually figured this out - realized I needed to create a basic variable for Role in the Flow, and then actually fill it using a lookup reference within a Process Builder flow.