I have the Opportunity object with children records called Workshare__c. There is a field on Workshare__c that is a percent (Work_Share_percent__c). We don't have any rollup fields available on the opportunity so I need to write a class that throws an error when a user tries to save a Workshare record and that record and all of its sibling's Work_Share_percent__c values are greater than 100%.
for example, I have an opportunity called 'Big Deal'. This 'Big Deal' Opportunity has 3 Workshare child records.
- Workshare A where Work_Share_percent__c = 50%
- Workshare B where Work_Share_percent__c = 20%
- Workshare C where Work_Share_percent__c = 10%
If I tried to create an additional Workshare child record on 'Big Deal' Opportunity, with a workshare_percent greater than 20% the user should be blocked from saving that record unless it is 20% or less.
I hope that makes sense and thanks in advance for your help.