Opportunity "Clone With Related" Roll-Up Issue
A Known Issue!
Salesforce have acknowledges that this is a Known Issue now!
This repo demonstrates a potential bug with roll-up summaries when an Opportunity is cloned with its related Opportunity
Products. The problem seems to be specific to roll-up summaries using a condition to count Opportunity Products.
If the count in the roll-up is 0, and then the Opportunity is cloned with related products, then the clone Opportunity
has a null
in the roll-up field instead of 0
.
Setup
- Use the associated config file roll-up-opp-products-scratch-def.json file to get the name used by later commands
- Push the source
sfdx force:source:push -u roll-up-opp-products
- Execute Apex to create an Opportunity
sfdx force:apex:execute --apexcodefile scripts/create_opportunity.apex -u roll-up-opp-products
- Open the org
sfdx force:org:open -u roll-up-opp-products
Reproduce
- Find the Opportunity called "Test Opportunity"
- Observe that it has values
1
and0
in the roll-up fields "# Lines With Quantity > 0" and "# Lines With Quantity > 1"
- Clone the Opportunity with related products
- Observe that the cloned Opportunity has
1
andnull
in the roll-up fields - Note that this is not a UI bug (i.e. not https://trailblazer.salesforce.com/issues_view?id=a1p3A000000IYvUQAW&title=lightning-rollup-summary-fields-are-not-updated-when-child-record-is-deleted) Test that by doing a query
sfdx force:data:soql:query -q "SELECT Id, Name, Lines_With_Quantity_gt_0__c, Lines_With_Quantity_gt_1__c FROM Opportunity" -u roll-up-opp-products
ID NAME LINES_WITH_QUANTITY_GT_0__C LINES_WITH_QUANTITY_GT_1__C
────────────────── ────────────────────── ─────────────────────────── ───────────────────────────
0062D00000G3riYQAR Test Opportunity 1 0
0062D00000G3rkKQAR Test Opportunity Clone 1 null
Total number of records retrieved: 2.
Querying Data... done