Skip to content

Commit 348ca00

Browse files
authored
V1.3.7 - Winter 22, Parent filtering support, Full recalc bugfix, Grandparent rollup bugfix (#180)
* Updating `RollupControl__mdt` fields to Subscriber controller * Fixes #173 with the addition of `RollupCalcItemReplacer` - removes some synchronous code from `Rollup.cls` that was previously replacing calc items in-situ when they had polymorphic where clauses, in favor of delegating when the replacement is made to the `RollupCalcItemReplacer`. Added `RollupControl__mdt.ReplaceCalcItemsAsyncWhenOverCount__c`, which is checked by the `RollupCalcItemReplacer` when considering whether to run sync or async * Start of fix for #179 by reproducing the issue in a test * Fixing typo in CDC method, cleaned up pre-work on `extra-tests/classes/CustomMetadataDrivenTests` prior to diving in * Fixes #179 by properly filtering CMDT records disassociated with the current rollup for grandparent rollups * Standardizing decimal handling to provide more flexibility for string inputs * Fixing issue with full recalc where too many query rows were sometimes retrieved * Bumping API version to 53 - upgraded plugins & apex-rollup to Winter22 * Bumping package version from Github Action
1 parent 4b97f4a commit 348ca00

File tree

90 files changed

+598
-287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+598
-287
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ You have several different options when it comes to making use of `Rollup`:
2121

2222
## Deployment
2323

24-
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Shn7AAC">
24+
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Si03AAC">
2525
<img alt="Deploy to Salesforce"
2626
src="./media/deploy-package-to-prod.png">
2727
</a>
2828

29-
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Shn7AAC">
29+
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Si03AAC">
3030
<img alt="Deploy to Salesforce Sandbox"
3131
src="./media/deploy-package-to-sandbox.png">
3232
</a>
@@ -159,9 +159,9 @@ These are the fields on the `Rollup Control` custom metadata type:
159159
- `Max Number Of Queries` - (defaults to 50) - Configure this number to decide how many queries Rollup is allowed to issue before restarting in another context. Consider the downstream query needs when your parent objects are updated when configuring this field. By safely requeueing Rollup in conjunction with this number, we ensure no query limit is ever hit.
160160
- `Max Rollup Retries` - (defaults to 100) - Only configurable on the Org Default record. Use in conjunction with `Max Query Rows`. This determines the maximum possible rollup jobs (either batched or queued) that can be spawned from a single overall rollup operation due to the prior one(s) exceeding the configured query limit.
161161
- `Batch Chunk Size` - (defaults to 2000) - The amount of records passed into each batchable job in the event that Rollup batches. Default is 2000, which is the vanilla Salesforce default for batch jobs.
162-
- `Is Rollup Logging Enabled` - (defaults to false) - Check this box in order to debug your rollups. Debug information is included in a few mission-critical pieces of Rollup to provide you with more information about where exactly an error might be occurring, should you encounter one.
162+
- `Is Rollup Logging Enabled` - (defaults to false) - Check this box in order to debug your rollups. Debug information is included in a few mission-critical pieces of Rollup to provide you with more information about where exactly an error might be occurring, should you encounter one. For more information, see the [Rollup Plugins](#rollup-plugins) section
163163
- `Is Merge Reparenting Enabled` - (defaults to true) - By default, if there is an `after delete` trigger context for Account / Case / Contact / Lead where Rollup is being used and one or more of those records is merged, Rollup goes and updates any children records from the old lookup to the new lookup automatically prior to recalculating rollup values. If you have pre-existing merge handling covered in your org by some other means, you should disable this checkbox and ensure that Rollup is only called _after_ your pre-existing merge handling has run.
164-
- `Rollup Logger Name` - (optional) - By default, if `Is Rollup Logging Enabled` is checked, logs associated with Rollup can be seen by keeping the Salesforce Developer Console open while inserting/updating records, or by starting a Debug Trace for a user. You also have the option of customizing how logs are displayed/stored. For more information, see the [Rollup Plugins](#rollup-plugins) section.
164+
- `Replace Calc Items Async When Over Count` - (defaults to 1) - in some instances, calc items passed into rollup need to be requeried - either to get additional fields (in the case of polymorphic queries), or if parent-level filters have been added to any rollup's `Calc Item Where Clause`. For these cases, we want to avoid adding unncessary queries to the sync portion of the run; we also want to avoid a slowdown in the sync processing time that `Rollup` requires. You can change this number from the default of 1 to 0 if you want any necessary replacement to _always_ happen in the async scope.
165165

166166
### Flow / Process Builder Invocable
167167

extra-tests/classes/CustomMetadataDrivenTests.cls

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@IsTest
22
private class CustomMetadataDrivenTests {
3-
43
@TestSetup
54
static void setup() {
65
upsert new RollupSettings__c(IsEnabled__c = true);
@@ -89,4 +88,36 @@ private class CustomMetadataDrivenTests {
8988
parent = [SELECT DateField__c FROM RollupParent__c WHERE Id = :parent.Id];
9089
System.assertEquals(childOne.DateField__c, parent.DateField__c);
9190
}
92-
}
91+
92+
@IsTest
93+
static void shouldRunCorrectlyForGrandparentReparenting() {
94+
Account greatGrandparent = new Account(Name = 'Great-grandparent');
95+
Account secondGreatGrandparent = new Account(Name = 'Second great-grandparent');
96+
insert new List<Account>{ greatGrandparent, secondGreatGrandparent };
97+
98+
ParentApplication__c grandParent = new ParentApplication__c(Name = 'Grandparent', Account__c = greatGrandparent.Id);
99+
ParentApplication__c secondGrandparent = new ParentApplication__c(Name = 'Second grandparent', Account__c = secondGreatGrandparent.Id);
100+
insert new List<ParentApplication__c>{ grandParent, secondGrandparent };
101+
102+
Application__c parent = new Application__c(Name = 'Parent-level', ParentApplication__c = grandParent.Id);
103+
Application__c secondParent = new Application__c(Name = 'Second parent-level', ParentApplication__c = secondGrandparent.Id);
104+
insert new List<Application__c>{ parent, secondParent };
105+
106+
ApplicationLog__c child = new ApplicationLog__c(Application__c = parent.Id, Name = greatGrandparent.Name);
107+
ApplicationLog__c secondChild = new ApplicationLog__c(Application__c = secondParent.Id, Name = secondGreatGrandparent.Name);
108+
insert new List<ApplicationLog__c>{ child, secondChild };
109+
110+
child = new ApplicationLog__c(Id = child.Id, Application__c = secondParent.Id, Name = 'Test Rollup Grandchildren Reparenting');
111+
secondChild = new ApplicationLog__c(Id = secondChild.Id, Name = 'Reparenting deux', Application__c = parent.Id);
112+
113+
Test.startTest();
114+
update new List<ApplicationLog__c>{ child, secondChild };
115+
Test.stopTest();
116+
117+
Account updatedGreatGrandparent = [SELECT Name FROM Account WHERE Id = :greatGrandparent.Id];
118+
Account updatedGreatGrandparentTwo = [SELECT Name FROM Account WHERE Id = :secondGreatGrandparent.Id];
119+
120+
System.assertEquals(secondChild.Name, updatedGreatGrandparent.Name, 'CONCAT_DISTINCT and reparenting should have worked');
121+
System.assertEquals(child.Name, updatedGreatGrandparentTwo.Name, 'CONCAT_DISTINCT and reparenting should have worked again');
122+
}
123+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>52.0</apiVersion>
3+
<apiVersion>53.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>52.0</apiVersion>
3+
<apiVersion>53.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>52.0</apiVersion>
3+
<apiVersion>53.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>52.0</apiVersion>
3+
<apiVersion>53.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>

extra-tests/classes/RollupEvaluatorTests.cls

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,4 +974,18 @@ private class RollupEvaluatorTests {
974974
System.assertEquals(true, eval.matches(new ContactPointAddress(Name = 'someValue', PreferenceRank = 1)));
975975
System.assertEquals(false, eval.matches(new ContactPointAddress(Name = 'someValue', PreferenceRank = 0)), 'cpa should not match');
976976
}
977+
978+
@IsTest
979+
static void shouldWorkWithoutDecimalZeroesForNumbers() {
980+
String whereClause = 'Amount = 50000';
981+
982+
RollupEvaluator.WhereFieldEvaluator eval = new RollupEvaluator.WhereFieldEvaluator(whereClause, Opportunity.SObjectType);
983+
984+
System.assertEquals(true, eval.matches(new Opportunity(Amount = 50000)));
985+
System.assertEquals(true, eval.matches(new Opportunity(Amount = 50000.00)), 'Should work with or without decimal places');
986+
System.assertEquals(false, eval.matches(new Opportunity(Amount = 50000.01)));
987+
988+
eval = new RollupEvaluator.WhereFieldEvaluator('Amount = 50.1', Opportunity.SObjectType);
989+
System.assertEquals(true, eval.matches(new Opportunity(Amount = 50.10)), 'Should detect trailing zero correctly');
990+
}
977991
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>52.0</apiVersion>
3+
<apiVersion>53.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>52.0</apiVersion>
3+
<apiVersion>53.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>52.0</apiVersion>
3+
<apiVersion>53.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>

0 commit comments

Comments
 (0)