Skip to content

Commit

Permalink
V1.2.30 - Equality check updates in Evaluator, recalc button bugfix (#…
Browse files Browse the repository at this point in the history
…124)

* Bump version for Summer21

* Fixes #123 by moving to strongly-typed equality checks for greater than / less than in RollupEvaluator

* Fixes #122 by properly filtering parent recalc button

* Fixing Datetime -> Date conversion issue reported by Katherine West

* Progress, still need to fix/adjust RollupRecursionItemTests

* Fixes #121 by properly decrementing count-based rollups when old calc item matches and updated version does not

* Fix getBareOperationName in Rollup

* Further work on #121 - working fix for UPDATE_COUNT, but further consideration needed for the following operations: UPDATE_COUNT_DISTINCT, UPDATE_SUM, UPDATE_CONCAT, UPDATE_CONCAT_DISTINCT, UPDATE_MIN, UPDATE_MAX. UPDATE_AVERAGE, UPDATE_FIRST, and UPDATE_LAST should already be good

* Updating package version in README
  • Loading branch information
jamessimone authored Jun 18, 2021
1 parent 5983bb1 commit e9aef85
Show file tree
Hide file tree
Showing 52 changed files with 510 additions and 116 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ Create fast, scalable custom rollups driven by Custom Metadata in your Salesforc

### Package deployment options

<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SgLWAA0">
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SgSsAAK">
<img alt="Deploy to Salesforce"
src="./media/deploy-package-to-prod.png">
</a>

<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SgLWAA0">
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SgSsAAK">
<img alt="Deploy to Salesforce"
src="./media/deploy-package-to-sandbox.png">
</a>
Expand Down
22 changes: 22 additions & 0 deletions extra-tests/classes/CustomMetadataDrivenTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,26 @@ private class CustomMetadataDrivenTests {
System.assertEquals(childOne.TextField__c, parent.TextField__c);
System.assertEquals(childOne.NumberField__c, parent.NumberField__c);
}

@isTest
static void regressionUpdatingEvalCriteriaShouldNotExcludeItemOnMultipleUpdatePath() {
// DateField__c rollup relies on NumberField > 0
RollupParent__c parent = [SELECT Id FROM RollupParent__c];
RollupChild__c childOne = new RollupChild__c(Name = 'Child one', DateField__c = System.today().addDays(3), RollupParent__c = parent.Id, NumberField__c = 0);

Test.startTest();

insert childOne;
childOne.DateField__c = childOne.DateField__c.addDays(-1);
update childOne;

// begin recursive update, but with a Calc Item Where Clause field change
childOne.NumberField__c = 1;
update childOne;

Test.stopTest();

parent = [SELECT DateField__c FROM RollupParent__c WHERE Id = :parent.Id];
System.assertEquals(childOne.DateField__c, parent.DateField__c);
}
}
2 changes: 1 addition & 1 deletion extra-tests/classes/CustomMetadataDrivenTests.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<apiVersion>52.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion extra-tests/classes/RollupIntegrationTests.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<apiVersion>52.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>RollupIntegrationChildRollupNumber</label>
<protected>false</protected>
<values>
<field>CalcItemWhereClause__c</field>
<value xsi:type="xsd:string">NumberField__c &gt; 0</value>
</values>
<values>
<field>CalcItem__c</field>
<value xsi:type="xsd:string">RollupChild__c</value>
</values>
<values>
<field>ChangedFieldsOnCalcItem__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>ConcatDelimiter__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>FullRecalculationDefaultNumberValue__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>FullRecalculationDefaultStringValue__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>GrandparentRelationshipFieldPath__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>IsFullRecordSet__c</field>
<value xsi:type="xsd:boolean">false</value>
</values>
<values>
<field>IsRollupStartedFromParent__c</field>
<value xsi:type="xsd:boolean">false</value>
</values>
<values>
<field>LookupFieldOnCalcItem__c</field>
<value xsi:type="xsd:string">RollupParent__c</value>
</values>
<values>
<field>LookupFieldOnLookupObject__c</field>
<value xsi:type="xsd:string">Id</value>
</values>
<values>
<field>LookupObject__c</field>
<value xsi:type="xsd:string">RollupParent__c</value>
</values>
<values>
<field>OrderByFirstLast__c</field>
<value xsi:nil="true"/>
</values>
<values>
<field>RollupControl__c</field>
<value xsi:type="xsd:string">Org_Defaults</value>
</values>
<values>
<field>RollupFieldOnCalcItem__c</field>
<value xsi:type="xsd:string">DateField__c</value>
</values>
<values>
<field>RollupFieldOnLookupObject__c</field>
<value xsi:type="xsd:string">DateField__c</value>
</values>
<values>
<field>RollupOperation__c</field>
<value xsi:type="xsd:string">LAST</value>
</values>
<values>
<field>RollupToUltimateParent__c</field>
<value xsi:type="xsd:boolean">false</value>
</values>
<values>
<field>UltimateParentLookup__c</field>
<value xsi:nil="true"/>
</values>
</CustomMetadata>
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@
<enableSearch>true</enableSearch>
<enableSharing>true</enableSharing>
<enableStreamingApi>true</enableStreamingApi>
<externalSharingModel>Private</externalSharingModel>
<label>Rollup Child</label>
<nameField>
<label>Rollup Child Name</label>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>DateField__c</fullName>
<externalId>false</externalId>
<label>Date Field</label>
<required>false</required>
<trackTrending>false</trackTrending>
<type>Date</type>
</CustomField>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>DateField__c</fullName>
<externalId>false</externalId>
<label>Date Field</label>
<required>false</required>
<trackTrending>false</trackTrending>
<type>Date</type>
</CustomField>
12 changes: 11 additions & 1 deletion extra-tests/profiles/Admin.profile-meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
<field>ParentApplication__c.Engagement_Rollup__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupChild__c.DateField__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupChild__c.TextField__c</field>
Expand All @@ -71,13 +76,18 @@
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupParent__c.TextField__c</field>
<field>RollupParent__c.DateField__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupParent__c.NumberField__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupParent__c.TextField__c</field>
<readable>true</readable>
</fieldPermissions>
<userLicense>Salesforce</userLicense>
</Profile>
2 changes: 1 addition & 1 deletion extra-tests/triggers/AccountTrigger.trigger-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<apiVersion>52.0</apiVersion>
<status>Active</status>
</ApexTrigger>
2 changes: 1 addition & 1 deletion extra-tests/triggers/ApplicationTrigger.trigger-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<apiVersion>52.0</apiVersion>
<status>Active</status>
</ApexTrigger>
2 changes: 1 addition & 1 deletion extra-tests/triggers/RollupChildTrigger.trigger-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<apiVersion>52.0</apiVersion>
<status>Active</status>
</ApexTrigger>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apex-rollup",
"version": "1.2.29.0",
"version": "1.2.30.0",
"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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('recalc parent rollup from flexipage tests', () => {
.then(() => {
// once recalc has finished ...
// we need to validate that what was sent includes our custom rollup invocation point
matchingMetadata[0].CalcItemWhereClause__c = "AccountId = '" + FAKE_RECORD_ID + "'";
matchingMetadata[0].CalcItemWhereClause__c = " ||| AccountId = '" + FAKE_RECORD_ID + "'";
expect(parentRecalcEl.shadowRoot.querySelector('lightning-spinner')).toBeFalsy();
expect(performBulkFullRecalc.mock.calls[0][0]).toEqual({ matchingMetadata, invokePointName: 'FROM_SINGULAR_PARENT_RECALC_LWC' });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import performBulkFullRecalc from '@salesforce/apex/Rollup.performBulkFullRecalc

import { getRollupMetadata } from 'c/rollupUtils';

const DELIMITER = ' ||| ';

export default class RecalculateParentRollupFlexipage extends LightningElement {
@api recordId;
@api objectApiName;
Expand Down Expand Up @@ -60,10 +62,11 @@ export default class RecalculateParentRollupFlexipage extends LightningElement {
" = '" +
this.recordId +
"'";

if (metadata.CalcItemWhereClause__c && metadata.CalcItemWhereClause__c.length > 0) {
metadata.CalcItemWhereClause__c = '(' + metadata.CalcItemWhereClause__c + ')' + ' AND ' + equalsParent;
metadata.CalcItemWhereClause__c = metadata.CalcItemWhereClause__c + DELIMITER + equalsParent;
} else {
metadata.CalcItemWhereClause__c = equalsParent;
metadata.CalcItemWhereClause__c = DELIMITER + equalsParent;
}
this._matchingMetas.push(metadata);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<apiVersion>52.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Recalc Rollups Button</masterLabel>
<targets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<apiVersion>52.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
Expand Down
2 changes: 1 addition & 1 deletion rollup/app/lwc/rollupUtils/rolupUtils.js-meta.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<apiVersion>52.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
Loading

0 comments on commit e9aef85

Please sign in to comment.