4

I want to insert opportunity splits based on below values:

Opportunity id
user 1,  amount - x
user 2,  amount - y
user 3,  amount - z

Looking at the fields of opportunity splits, we have field SplitAmount.

I am trying to execute following snippet in execute anonymous as below:

list< Opportunity > opp =  new list< Opportunity >();  
opp = [SELECT Id,Oppty_Supported_By__c,OwnerId, Renewal_ACV__c, Upsell_ACV__c FROM Opportunity];  
for(Opportunity o: opp)    
{  
OpportunitySplit ost = new OpportunitySplit();  
ost.OpportunityId=o.id;  
ost.SplitOwnerId=o.ownerid;  
ost.SplitAmount=o.Upsell_ACV__c;  

opp.add(ost);  

OpportunitySplit ost1 = new OpportunitySplit();  
ost1.OpportunityId=o.id;  
ost1.SplitOwnerId=o.Oppty_Supported_By__c;  
ost1.SplitAmount=o.Renewal_ACV__c;  
opp.add(ost1);  
}  

upsert opp;  

but getting the error as:

COMPILE ERROR: Field is not writeable: OpportunitySplit.SplitAmount

Is there any workaround?

3
  • 4
    It looks like you can only split by percent of a field. Try creating a split for your currency fields, and then creating splits that are 100%.
    – sfdcfox
    Commented Feb 6, 2015 at 20:35
  • Going to try that @sfdcfox!! thanks for the suggestion !!!
    – C0DEPirate
    Commented Feb 6, 2015 at 20:43
  • 3
    In situations like this, your friend is this doc: salesforce.com/us/developer/docs/object_reference/index.htm - look up the fields in SObject OpportunitySplit. The field SplitAmount is not marked with property Update indicating it is a derived field by SFDC. You'll want to set field SplitPercentage as @sfdcfox indicated
    – cropredy
    Commented Feb 7, 2015 at 1:33

1 Answer 1

2

Checked the Documentation shared by @crop1645. As the field property says updateable: false. Hence the answer is no and it is not possible.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .