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?
OpportunitySplit
. The fieldSplitAmount
is not marked with propertyUpdate
indicating it is a derived field by SFDC. You'll want to set fieldSplitPercentage
as @sfdcfox indicated