I'm trying to automate Opportunity Splits and I'm running into the following when trying to upsert them for a given split type:

System.DmlException: Upsert failed. First exception on row 0 with id 0492M0000034GO5QAM; first error: FIELD_INTEGRITY_EXCEPTION, Can't update splits: percentages don't add up to 100.00%.: []

Except they do add up to 100.00%. Here's a script that you can run to see the error. You just need the default revenue split enabled in the org and one other standard user. Note the asserts to validate that it does indeed add up to 100%.

Account a = new Account(Name = 'My Account');
insert a;

String stageName = [SELECT ApiName FROM OpportunityStage WHERE IsClosed = FALSE LIMIT 1].ApiName;

Opportunity o = new Opportunity(Name = 'My Opportunity', StageName = stageName, CloseDate = Date.today());
insert o;

Id revenueSplitTypeId = [SELECT Id FROM OpportunitySplitType WHERE DeveloperName = 'Revenue'].Id;

User splitUser = [SELECT Id FROM User WHERE UserType = 'Standard' AND Profile.Name = 'Standard User' LIMIT 1];

OpportunitySplit existingSplit = [SELECT SplitPercentage FROM OpportunitySplit WHERE OpportunityId = :o.Id];

System.assertEquals(100, existingSplit.SplitPercentage);
existingSplit.SplitPercentage = 75.00;

OpportunitySplit newSplit = new OpportunitySplit(
        SplitTypeId = revenueSplitTypeId,
        OpportunityId = o.Id,
        SplitOwnerId = splitUser.Id,
        SplitPercentage = 25.00

System.assertEquals(100.00, existingSplit.SplitPercentage + newSplit.SplitPercentage);
upsert new List<OpportunitySplit>{existingSplit, newSplit};

Is this related to how upsert operations work? If upsert won't work, how else am I supposed to modify splits? Do I have to insert new ones as 0%, then do an update on all of them?

1 Answer 1


This appears to me to be an erroneous Salesforce error message. Add the following line after retrieving splitUser and the error disappears:

insert new OpportunityTeamMember(UserId = splitUser.Id, OpportunityId = o.Id);

Apparently Salesforce sums up only those records, which stem from Opportunity Team Members.

You must log in to answer this question.

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