Skip to content

Commit

Permalink
v1.7.9 - Introduces Rollup__mdt.IsDisabled__c flag (#663)
Browse files Browse the repository at this point in the history
* Adds Rollup__mdt.IsDisabled__c option

* Upgraded to API version 63
  • Loading branch information
jamessimone authored Feb 21, 2025
1 parent e1a00a6 commit a5204d0
Show file tree
Hide file tree
Showing 60 changed files with 194 additions and 66 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ As well, don't miss [the Wiki](../../wiki), which includes even more info for co

## Deployment & Setup

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

<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008OfrvAAC">
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008OfsPAAS">
<img alt="Deploy to Salesforce Sandbox" src="./media/deploy-package-to-sandbox.png">
</a>
<br/>
Expand Down Expand Up @@ -146,6 +146,7 @@ Within the `Rollup__mdt` custom metadata type, add a new record with fields:
- `Group By Row Start Delimiter` (optional) - if set, this is the delimiter which prefaces each row in the group by rollup to delimit results. Defaults to `` if not supplied
- `Group By Row End Delimiter` (optional) - if set, this is the delimiter which is appended to each row in the group by rollup to delimit results. Defaults to a new line character if not supplied. Please also note that different new line characters are required depending on what type of field you're rolling up to - `<br>` will work for Rich Text fields, for example, while `\n` is the way to enter new lines for long text areas
- `Is Distinct` (optional, defaults to `false`) - de-duplicates the children item values for any parent prior to rolling them up
- `Is Disabled` (optional, defaults to `false`) - toggle this to omit a rollup from being run without having to associate it with another Rollup Control record
- `Is Full Record Set` (optional, defaults to `false`) - converts any rollup into a full recalculation (e.g. all _other_ child records associated with the parent(s) of the child records being passed in will be fetched and used in the rollup calculation)
- `Is Rollup Started From Parent` (optional, defaults to `false`) - if the the records being passed in are the parent records, check this field off. Apex Rollup will then go and retrieve the assorted children records before rolling the values up to the parents. If you are using `Is Rollup Started From Parent` and grandparent rollups with Tasks/Events (or anything with a polymorphic relationship field like `Who` or `What` on Task/Event; the `Parent` field on `Contact Point Address` is another example of such a field), you **must** also include a filter for `What.Type` or `Who.Type` in your `Child Object Where Clause` in order to proceed, e.g. `What.Type = 'Account'`.
- `Is Table Formatted` (optional, defaults to `false`) - set this to true _instead of_ using the `Group By Row Start Delimiter` and `Group By Row End Delimiter` if you are rolling up to a rich text field and you want the output to be a table.
Expand Down
14 changes: 14 additions & 0 deletions extra-tests/classes/RollupRepositoryTests.cls
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
@IsTest
private class RollupRepositoryTests {
@IsTest
static void omitsDisabledRollups() {
List<Rollup__mdt> metas = RollupRepository.getRollupMetadata();

Boolean foundDisabled = false;
for (Rollup__mdt actualMeta : metas) {
if (actualMeta.IsDisabled__c) {
foundDisabled = true;
throw new IllegalArgumentException('Found disabled metadata: ' + JSON.serialize(actualMeta));
}
}
Assert.isFalse(foundDisabled);
}

@IsTest
static void transformsCountQueriesProperly() {
String queryString = 'SELECT Id, AnnualRevenue, Name\nFROM Account';
Expand Down
93 changes: 93 additions & 0 deletions extra-tests/customMetadata/Rollup.OpportunityDisabled.md-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?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>Opportunity Disabled</label>
<protected>false</protected>
<values>
<field>CalcItemWhereClause__c</field>
<value xsi:nil="true" />
</values>
<values>
<field>CalcItem__c</field>
<value xsi:type="xsd:string">Opportunity</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>IsDisabled__c</field>
<value xsi:type="xsd:boolean">true</value>
</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">AccountId</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">Account</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">Amount</value>
</values>
<values>
<field>RollupFieldOnLookupObject__c</field>
<value xsi:type="xsd:string">AnnualRevenue</value>
</values>
<values>
<field>RollupOperation__c</field>
<value xsi:type="xsd:string">SUM</value>
</values>
<values>
<field>RollupToUltimateParent__c</field>
<value xsi:type="xsd:boolean">false</value>
</values>
<values>
<field>SplitConcatDelimiterOnCalcItem__c</field>
<value xsi:type="xsd:boolean">false</value>
</values>
<values>
<field>UltimateParentLookup__c</field>
<value xsi:nil="true" />
</values>
</CustomMetadata>
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.7.8",
"version": "1.7.9",
"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
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexTrigger>
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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion plugins/NebulaLogger/tests/LogBatchPurgerAll.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion plugins/RollupCallback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class RollupChangeNotifier extends LightningElement {
<!-- in rollupChangeNotifier.js-meta.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Rollup Change Notifier</masterLabel>
<targets>
Expand Down
2 changes: 1 addition & 1 deletion plugins/RollupCallback/classes/RollupDispatch.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
4 changes: 2 additions & 2 deletions rollup-namespaced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ For more info, see the base `README`.

## Deployment & Setup

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

<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008Ofs0AAC">
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008OfsUAAS">
<img alt="Deploy to Salesforce Sandbox"
src="./media/deploy-package-to-sandbox.png">
</a>
7 changes: 4 additions & 3 deletions rollup-namespaced/sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"default": true,
"package": "apex-rollup-namespaced",
"path": "rollup-namespaced/source/rollup",
"versionName": "Properly handle namespaced and other Type__c fields in RollupCalcItemReplacer",
"versionNumber": "1.2.7.0",
"versionName": "Allows individual rollup records to be disabled on Rollup Metadata records",
"versionNumber": "1.2.8.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": {
Expand All @@ -32,6 +32,7 @@
"[email protected]": "04t6g000008OfqYAAS",
"[email protected]": "04t6g000008OfrCAAS",
"[email protected]": "04t6g000008OfrqAAC",
"[email protected]": "04t6g000008Ofs0AAC"
"[email protected]": "04t6g000008Ofs0AAC",
"[email protected]": "04t6g000008OfsUAAS"
}
}
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>62.0</apiVersion>
<apiVersion>63.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
Expand Down
2 changes: 1 addition & 1 deletion rollup/app/lwc/rollupOrderBy/rollupOrderBy.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
9 changes: 5 additions & 4 deletions rollup/core/classes/Rollup.cls
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,12 @@ global without sharing virtual class Rollup implements RollupLogger.ToStringObje
Map<String, List<Rollup__mdt>> calcItemToMetadata = new Map<String, List<Rollup__mdt>>();
List<Rollup__mdt> localMetadata = getMetadataFromCache(Rollup__mdt.SObjectType);
for (Rollup__mdt localMeta : localMetadata) {
if (calcItemToMetadata.containsKey(localMeta.CalcItem__c)) {
calcItemToMetadata.get(localMeta.CalcItem__c).add(localMeta);
} else {
calcItemToMetadata.put(localMeta.CalcItem__c, new List<Rollup__mdt>{ localMeta });
List<Rollup__mdt> childrenMetadata = calcItemToMetadata.get(localMeta.CalcItem__c);
if (childrenMetadata == null) {
childrenMetadata = new List<Rollup__mdt>();
calcItemToMetadata.put(localMeta.CalcItem__c, childrenMetadata);
}
childrenMetadata.add(localMeta);
}
return calcItemToMetadata;
}
Expand Down
2 changes: 1 addition & 1 deletion rollup/core/classes/Rollup.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion rollup/core/classes/RollupAsyncProcessor.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion rollup/core/classes/RollupCalcItemReplacer.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion rollup/core/classes/RollupCalcItemSorter.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion rollup/core/classes/RollupCalculator.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion rollup/core/classes/RollupCurrencyInfo.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion rollup/core/classes/RollupDateLiteral.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion rollup/core/classes/RollupEvaluator.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion rollup/core/classes/RollupFieldInitializer.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>62.0</apiVersion>
<apiVersion>63.0</apiVersion>
<status>Active</status>
</ApexClass>
Loading

0 comments on commit a5204d0

Please sign in to comment.