3

I am 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 I decided to automate these through a trigger.

  1. I 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%, I 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"

Does anyone has experience this while attempting to do the same?

2
  • 2
    How is OpportunitySplitType.IsTotalValidated defined? can you make this false and have code ensure %s add up to 100?
    – cropredy
    Commented Oct 15, 2015 at 16:06
  • 1
    Can I suggest that you post your code here so we can take a look? It's hard to debug without it. Commented Oct 15, 2015 at 17:03

2 Answers 2

1

I don't know that this is an answer but I wanted to share what I have discovered in doing a dataload of Splits. Same as you I can add and remove Opportunity Team members easily but I was getting really weird errors when saving Splits. Things like 'required field not supplied: U#455.11FF'. Anyway what I also found was that trying to provide all pieces for the fully calculated split didn't work either.

The Opportunity owner is always on the split at 100%. Instead of updating them to 50% and adding someone else at 50% I just added the other party at 50% and this worked. Salesforce is obviously doing the calc of the Opportunity owner as the remainder after the other splits are added.

1

I recently created some automation to modify Opportunity Split percentages and users for the OpportunitySplit standard object via Apex and found that the following approach of 3 DML statements works to avoid the "Can't update splits: percentages don't add up to 100.00%" error.

  1. Insert OpportunitySplits. For each user that doesn't currently have a split but needs one, add a split for the user, but set the SplitPercentage field value to 0.

  2. Update Opportunity Splits. In this update call, you will need to A) update pre-existing splits that you want to discard to a SplitPercentage of 0, B) update the SplitPercentage of the splits you inserted in the previous step to the final desired SplitPercentage, and C) update any pre-existing splits that you want to keep to the final desired SplitPercentage.

  3. Delete Opportunity Splits. Delete any splits you want to discard. These should already have had the SplitPercentage set to 0 in the update call above.

You must log in to answer this question.

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