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
Yanick Nantchouang 6Yanick Nantchouang 6 

Automatically create Opportunity Splits through a trigger, Error Message is "percentages don't add up to 100% "

Hi All,

We are looking to automate the creation of Opportunity Splits on each opportunity as we cannot trust Sales Reps to add the Opportunity Team and Opportunity Splits accurately. So we decided to automate these through a trigger.

1- We can add and remove the 3 members to the Opportunity Team no problem.
2- When attempting to add the 3 members with the following percentages to the Opportunity Splits: 80%, 10%, 10%, we get an error suggesting that the percentages don't add up to 100% .

FULL ERROR MESSAGE: "caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Can't update splits: percentages don't add up to 100.00%.: []: Class.CreateOppoTeamMember.CreateOppoSlpits: line 187, column 1"

Any help to resolve this will be greatly appreciated

 
daniel_hdaniel_h
I wonder if there is already a split for the owner of 100% and by adding three more, you are now at 200%? Have you tried checking for any existing splits before adding the new ones?