From 0affa063a2902f260512d6bb910313f71ad02e3d Mon Sep 17 00:00:00 2001 From: James Simone Date: Thu, 14 Dec 2023 09:45:42 -0500 Subject: [PATCH 1/4] Updates to CREATE and GAP_CREATE logic for CDC --- extra-tests/classes/RollupTests.cls | 1 - rollup/core/classes/Rollup.cls | 3 ++- sfdx-project.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extra-tests/classes/RollupTests.cls b/extra-tests/classes/RollupTests.cls index 1b479220..e2c44c1c 100644 --- a/extra-tests/classes/RollupTests.cls +++ b/extra-tests/classes/RollupTests.cls @@ -2319,7 +2319,6 @@ private class RollupTests { EventBus.ChangeEventHeader header = new EventBus.ChangeEventHeader(); header.changeType = 'CREATE'; - header.changedFields = new List{ 'PreferenceRank', 'LastModifiedDate' }; header.recordIds = new List{ cpa.Id }; header.entityName = 'ContactPointAddress'; ContactPointAddressChangeEvent ev = new ContactPointAddressChangeEvent(ChangeEventHeader = header, PreferenceRank = 500); diff --git a/rollup/core/classes/Rollup.cls b/rollup/core/classes/Rollup.cls index 8bc406e5..2357548d 100644 --- a/rollup/core/classes/Rollup.cls +++ b/rollup/core/classes/Rollup.cls @@ -1629,7 +1629,8 @@ global without sharing virtual class Rollup implements RollupLogger.ToStringObje return; } - Set uniqueFieldNames = new Set(); + Set uniqueFieldNames = new Set(firstRecord.getPopulatedFieldsAsMap().keySet()); + uniqueFieldNames.remove('ChangeEventHeader'); RollupRepository.RunAsMode permissionLevel = RollupRepository.RunAsMode.SYSTEM_LEVEL; for (Rollup__mdt rollupInfo : matchingMetadata) { permissionLevel = RollupMetaPicklists.getAccessLevel(rollupInfo); diff --git a/sfdx-project.json b/sfdx-project.json index f2685130..99009f64 100644 --- a/sfdx-project.json +++ b/sfdx-project.json @@ -4,8 +4,8 @@ "default": true, "package": "apex-rollup", "path": "rollup", - "versionName": "Flow optimizations continued", - "versionNumber": "1.6.6.0", + "versionName": "CDC create updates", + "versionNumber": "1.6.7.0", "versionDescription": "Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.", "releaseNotesUrl": "https://github.com/jamessimone/apex-rollup/releases/latest", "unpackagedMetadata": { From df851125ec38172c9dff50c1138ce577fd69f02d Mon Sep 17 00:00:00 2001 From: James Simone Date: Fri, 15 Dec 2023 11:47:43 -0500 Subject: [PATCH 2/4] Added undelete context for CDC --- rollup/core/classes/Rollup.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollup/core/classes/Rollup.cls b/rollup/core/classes/Rollup.cls index 2357548d..22f6753c 100644 --- a/rollup/core/classes/Rollup.cls +++ b/rollup/core/classes/Rollup.cls @@ -1642,7 +1642,7 @@ global without sharing virtual class Rollup implements RollupLogger.ToStringObje // it would have been nice if this was an enum! switch on header.changeType { - when 'CREATE', 'GAP_CREATE' { + when 'CREATE', 'GAP_CREATE', 'UNDELETE' { apexContext = TriggerOperation.AFTER_INSERT; } when 'UPDATE', 'GAP_UPDATE' { From a49cd942b80ddcc463cee1759ec22b8cab3c55ab Mon Sep 17 00:00:00 2001 From: James Simone Date: Fri, 15 Dec 2023 11:58:36 -0500 Subject: [PATCH 3/4] Fixes run without children support for refresh flows that pass Parent Record Id For Empty Children Collection argument when Get Records returns no children for a given parent --- extra-tests/classes/RollupFlowTests.cls | 1 + rollup/core/classes/Rollup.cls | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/extra-tests/classes/RollupFlowTests.cls b/extra-tests/classes/RollupFlowTests.cls index 290f0b6a..e38f9e57 100644 --- a/extra-tests/classes/RollupFlowTests.cls +++ b/extra-tests/classes/RollupFlowTests.cls @@ -1022,6 +1022,7 @@ private class RollupFlowTests { RollupAsyncProcessor.stubParentRecords = new List{ acc }; List flowInputs = RollupTestUtils.prepareFlowTest(new List(), 'REFRESH', 'SUM'); + flowInputs[0].recordsToRollup = null; // Get Records passes null for something that doesn't match flowInputs[0].parentRecordIdForEmptyChildrenCollections = acc.Id; flowInputs[0].calcItemTypeWhenRollupStartedFromParent = 'ContactPointAddress'; diff --git a/rollup/core/classes/Rollup.cls b/rollup/core/classes/Rollup.cls index 22f6753c..2cfe1fde 100644 --- a/rollup/core/classes/Rollup.cls +++ b/rollup/core/classes/Rollup.cls @@ -784,8 +784,9 @@ global without sharing virtual class Rollup implements RollupLogger.ToStringObje if ( flowInput.parentRecordIdForEmptyChildrenCollections != null && flowInput.calcItemTypeWhenRollupStartedFromParent != null && - flowInput.recordsToRollup?.isEmpty() == true + flowInput.recordsToRollup?.isEmpty() != false ) { + flowInput.recordsToRollup = new List(); Schema.DescribeSObjectResult childDescribe = RollupFieldInitializer.Current.getDescribeFromName(flowInput.calcItemTypeWhenRollupStartedFromParent); SObject stubChild = childDescribe.getSObjectType().newSObject(childDescribe.getKeyPrefix() + '0'.repeat(12)); stubChild.put(flowInput.lookupFieldOnCalcItem, flowInput.parentRecordIdForEmptyChildrenCollections); From 443481fd966216981df87afac5bb570c7207ac96 Mon Sep 17 00:00:00 2001 From: James Simone Date: Wed, 20 Dec 2023 19:15:15 -0500 Subject: [PATCH 4/4] Upgrades packages [skip ci] --- package.json | 2 +- rollup-namespaced/sfdx-project.json | 3 ++- rollup/core/classes/RollupFullRecalcProcessor.cls | 2 +- rollup/core/classes/RollupLogger.cls | 2 +- sfdx-project.json | 3 ++- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index af18eb27..f6761af7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "apex-rollup", - "version": "1.6.6", + "version": "1.6.7", "description": "Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.", "repository": { "type": "git", diff --git a/rollup-namespaced/sfdx-project.json b/rollup-namespaced/sfdx-project.json index 37371092..b99c5de3 100644 --- a/rollup-namespaced/sfdx-project.json +++ b/rollup-namespaced/sfdx-project.json @@ -30,6 +30,7 @@ "apex-rollup-namespaced@1.1.3": "04t6g000008Oa8lAAC", "apex-rollup-namespaced@1.1.4": "04t6g000008Oa9ZAAS", "apex-rollup-namespaced@1.1.5": "04t6g000008OaAcAAK", - "apex-rollup-namespaced@1.1.6": "04t6g000008OaFnAAK" + "apex-rollup-namespaced@1.1.6": "04t6g000008OaFnAAK", + "apex-rollup-namespaced@1.1.7": "04t6g000008OaHPAA0" } } \ No newline at end of file diff --git a/rollup/core/classes/RollupFullRecalcProcessor.cls b/rollup/core/classes/RollupFullRecalcProcessor.cls index b75f8ea3..fe2b603a 100644 --- a/rollup/core/classes/RollupFullRecalcProcessor.cls +++ b/rollup/core/classes/RollupFullRecalcProcessor.cls @@ -162,7 +162,7 @@ global abstract without sharing class RollupFullRecalcProcessor extends RollupAs protected override Boolean getCanRollupWithoutCustomSetting() { Boolean canRollupWithoutCustomSetting = false; for (Rollup__mdt rollupMeta : this.rollupMetas) { - canRollupWithoutCustomSetting = rollupMeta.ShouldRunWithoutCustomSettingEnabled__c == true; + canRollupWithoutCustomSetting = rollupMeta.ShouldRunWithoutCustomSettingEnabled__c; // all included rollups need to have the override enabled; if even one does NOT, we can stop if (canRollupWithoutCustomSetting == false) { break; diff --git a/rollup/core/classes/RollupLogger.cls b/rollup/core/classes/RollupLogger.cls index bf919057..c1de1a4b 100644 --- a/rollup/core/classes/RollupLogger.cls +++ b/rollup/core/classes/RollupLogger.cls @@ -1,7 +1,7 @@ global without sharing virtual class RollupLogger implements ILogger { @TestVisible // this gets updated via the pipeline as the version number gets incremented - private static final String CURRENT_VERSION_NUMBER = 'v1.6.6'; + private static final String CURRENT_VERSION_NUMBER = 'v1.6.7'; private static final LoggingLevel FALLBACK_LOGGING_LEVEL = LoggingLevel.DEBUG; private static final RollupPlugin PLUGIN = new RollupPlugin(); diff --git a/sfdx-project.json b/sfdx-project.json index 99009f64..d44cf5af 100644 --- a/sfdx-project.json +++ b/sfdx-project.json @@ -108,6 +108,7 @@ "apex-rollup@1.6.3": "04t6g000008Oa8gAAC", "apex-rollup@1.6.4": "04t6g000008Oa9UAAS", "apex-rollup@1.6.5": "04t6g000008OaAXAA0", - "apex-rollup@1.6.6": "04t6g000008OaFiAAK" + "apex-rollup@1.6.6": "04t6g000008OaFiAAK", + "apex-rollup@1.6.7": "04t6g000008OaHKAA0" } } \ No newline at end of file