diff --git a/extra-tests/classes/RollupCalcItemSorterTests.cls b/extra-tests/classes/RollupCalcItemSorterTests.cls index 44037d26..16daab5f 100644 --- a/extra-tests/classes/RollupCalcItemSorterTests.cls +++ b/extra-tests/classes/RollupCalcItemSorterTests.cls @@ -162,7 +162,7 @@ private class RollupCalcItemSorterTests { new Opportunity(StageName = 'One') }; - itemsToSort.sort(new RollupCalcItemSorter(new List{ Opportunity.Name.getDescribe().getName(), Opportunity.StageName.getDescribe().getName() })); + itemsToSort.sort(new RollupCalcItemSorter(new List{ Opportunity.Name.toString(), Opportunity.StageName.toString() })); System.assertEquals(null, itemsToSort.get(0).StageName); System.assertEquals('One', itemsToSort.get(1).StageName); diff --git a/extra-tests/classes/RollupCurrencyInfoTests.cls b/extra-tests/classes/RollupCurrencyInfoTests.cls index d6256a94..4c55a072 100644 --- a/extra-tests/classes/RollupCurrencyInfoTests.cls +++ b/extra-tests/classes/RollupCurrencyInfoTests.cls @@ -206,7 +206,7 @@ private class RollupCurrencyInfoTests { ); List olis = new List{ oliToUpdate }; - RollupCurrencyInfo.overrideDatedMultiCurrency(olis.getSObjectType().getDescribe().getName(), new List{ 'Opportunity', 'CloseDate' }); + RollupCurrencyInfo.overrideDatedMultiCurrency(olis.getSObjectType().toString(), new List{ 'Opportunity', 'CloseDate' }); RollupCurrencyInfo.transform(olis, OpportunityLineItem.TotalPrice, eurPeriodOne.IsoCode, new List()); OpportunityLineItem oli = (OpportunityLineItem) RollupCurrencyInfo.getCalcItem(oliToUpdate, eurPeriodOne.IsoCode); diff --git a/extra-tests/classes/RollupEvaluatorTests.cls b/extra-tests/classes/RollupEvaluatorTests.cls index 18516c0c..98f502f8 100644 --- a/extra-tests/classes/RollupEvaluatorTests.cls +++ b/extra-tests/classes/RollupEvaluatorTests.cls @@ -1129,7 +1129,7 @@ private class RollupEvaluatorTests { @IsTest static void pascalCaseForFieldNamesIsNotRequired() { - String poorlyCasedFieldName = Opportunity.IsClosed.getDescribe().getName().toLowerCase(); + String poorlyCasedFieldName = Opportunity.IsClosed.toString().toLowerCase(); Opportunity isClosedFalse = (Opportunity) JSON.deserialize('{ "IsClosed": false }', Opportunity.class); OpportunityLineItem target = new OpportunityLineItem(Opportunity = isClosedFalse); diff --git a/extra-tests/classes/RollupFlowFullRecalcTests.cls b/extra-tests/classes/RollupFlowFullRecalcTests.cls index 2e9e80fd..a8498024 100644 --- a/extra-tests/classes/RollupFlowFullRecalcTests.cls +++ b/extra-tests/classes/RollupFlowFullRecalcTests.cls @@ -28,8 +28,8 @@ private class RollupFlowFullRecalcTests { List flowInputs = RollupTestUtils.prepareFlowTest(apps, 'REFRESH', 'SUM'); flowInputs[0].ultimateParentLookup = 'ParentId'; flowInputs[0].rollupToUltimateParent = true; - flowInputs[0].lookupFieldOnCalcItem = Application__c.ParentApplication__c.getDescribe().getName(); - flowInputs[0].rollupFieldOnCalcItem = Application__c.Engagement_Score__c.getDescribe().getName(); + flowInputs[0].lookupFieldOnCalcItem = Application__c.ParentApplication__c.toString(); + flowInputs[0].rollupFieldOnCalcItem = Application__c.Engagement_Score__c.toString(); flowInputs[0].grandparentRelationshipFieldPath = RollupTestUtils.getRelationshipPath( new List{ Application__c.ParentApplication__c, ParentApplication__c.Account__c, Account.AnnualRevenue } ); diff --git a/extra-tests/classes/RollupFullRecalcTests.cls b/extra-tests/classes/RollupFullRecalcTests.cls index b0b291a9..cc34928b 100644 --- a/extra-tests/classes/RollupFullRecalcTests.cls +++ b/extra-tests/classes/RollupFullRecalcTests.cls @@ -124,14 +124,14 @@ private class RollupFullRecalcTests { List metadata = new List{ new Rollup__mdt( - CalcItem__c = Application__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(), + CalcItem__c = Application__c.SObjectType.toString(), LookupObject__c = 'Account', RollupToUltimateParent__c = true, - LookupFieldOnCalcItem__c = Application__c.ParentApplication__c.getDescribe().getName(), + LookupFieldOnCalcItem__c = Application__c.ParentApplication__c.toString(), UltimateParentLookup__c = 'ParentId', RollupOperation__c = 'SUM', RollupFieldOnLookupObject__c = 'AnnualRevenue', - RollupFieldOnCalcItem__c = Application__c.Engagement_Score__c.getDescribe().getName(), + RollupFieldOnCalcItem__c = Application__c.Engagement_Score__c.toString(), LookupFieldOnLookupObject__c = 'Id', GrandparentRelationshipFieldPath__c = RollupTestUtils.getRelationshipPath( new List{ Application__c.ParentApplication__c, ParentApplication__c.Account__c, Account.AnnualRevenue } @@ -168,12 +168,12 @@ private class RollupFullRecalcTests { List metadata = new List{ new Rollup__mdt( - CalcItem__c = Application__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(), + CalcItem__c = Application__c.SObjectType.toString(), LookupObject__c = 'Individual', - LookupFieldOnCalcItem__c = Application__c.ParentApplication__c.getDescribe().getName(), + LookupFieldOnCalcItem__c = Application__c.ParentApplication__c.toString(), RollupOperation__c = 'SUM', RollupFieldOnLookupObject__c = 'ConsumerCreditScore', - RollupFieldOnCalcItem__c = Application__c.Engagement_Score__c.getDescribe().getName(), + RollupFieldOnCalcItem__c = Application__c.Engagement_Score__c.toString(), LookupFieldOnLookupObject__c = 'Id', GrandparentRelationshipFieldPath__c = String.valueOf(Application__c.ParentApplication__c).replace('__r', '__c') + '.' + @@ -939,7 +939,7 @@ private class RollupFullRecalcTests { System.assertEquals( 'Completed', [ - SELECT Status, ApexClass.Name + SELECT Status FROM AsyncApexJob WHERE JobType = 'Queueable' AND ApexClass.Name = :getNamespaceSafeClassName(RollupFullBatchRecalculator.class) LIMIT 1 @@ -1207,12 +1207,12 @@ private class RollupFullRecalcTests { List metas = new List{ new Rollup__mdt( - CalcItem__c = RollupChild__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(), - RollupFieldOnCalcItem__c = RollupChild__c.NumberField__c.getDescribe().getName(), - LookupFieldOnCalcItem__c = RollupChild__c.RollupParent__c.getDescribe().getName(), - LookupObject__c = RollupGrandparent__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(), - LookupFieldOnLookupObject__c = RollupGrandparent__c.Id.getDescribe().getName(), - RollupFieldOnLookupObject__c = RollupGrandparent__c.AmountFromChildren__c.getDescribe().getName(), + CalcItem__c = RollupChild__c.SObjectType.toString(), + RollupFieldOnCalcItem__c = RollupChild__c.NumberField__c.toString(), + LookupFieldOnCalcItem__c = RollupChild__c.RollupParent__c.toString(), + LookupObject__c = RollupGrandparent__c.SObjectType.toString(), + LookupFieldOnLookupObject__c = RollupGrandparent__c.Id.toString(), + RollupFieldOnLookupObject__c = RollupGrandparent__c.AmountFromChildren__c.toString(), RollupOperation__c = 'SUM', CalcItemWhereClause__c = ' ||| ' + RollupTestUtils.getRelationshipPath( diff --git a/extra-tests/classes/RollupIntegrationTests.cls b/extra-tests/classes/RollupIntegrationTests.cls index d8cb063b..922227b0 100644 --- a/extra-tests/classes/RollupIntegrationTests.cls +++ b/extra-tests/classes/RollupIntegrationTests.cls @@ -36,8 +36,8 @@ private class RollupIntegrationTests { new Rollup__mdt( RollupFieldOnCalcItem__c = 'Amount', LookupObject__c = 'Account', - LookupFieldOnCalcItem__c = Opportunity.AccountIdText__c.getDescribe().getName(), - LookupFieldOnLookupObject__c = Account.AccountIdText__c.getDescribe().getName(), + LookupFieldOnCalcItem__c = Opportunity.AccountIdText__c.toString(), + LookupFieldOnLookupObject__c = Account.AccountIdText__c.toString(), RollupFieldOnLookupObject__c = 'AnnualRevenue', RollupOperation__c = 'MAX', CalcItem__c = 'Opportunity' @@ -68,7 +68,7 @@ private class RollupIntegrationTests { Rollup.rollupMetadata = new List{ new Rollup__mdt( - RollupFieldOnCalcItem__c = Opportunity.AmountFormula__c.getDescribe().getName(), + RollupFieldOnCalcItem__c = Opportunity.AmountFormula__c.toString(), LookupObject__c = 'Account', LookupFieldOnCalcItem__c = 'AccountId', LookupFieldOnLookupObject__c = 'Id', @@ -150,19 +150,15 @@ private class RollupIntegrationTests { Rollup.records = applications; Rollup.FlowInput input = new Rollup.FlowInput(); - input.lookupFieldOnCalcItem = Application__c.ParentApplication__c.getDescribe().getName(); + input.lookupFieldOnCalcItem = Application__c.ParentApplication__c.toString(); input.lookupFieldOnOpObject = 'Id'; input.recordsToRollup = applications; input.rollupContext = 'INSERT'; - input.rollupFieldOnCalcItem = Application__c.Engagement_Score__c.getDescribe().getName(); - input.rollupFieldOnOpObject = ParentApplication__c.Engagement_Rollup__c.getDescribe().getName(); + input.rollupFieldOnCalcItem = Application__c.Engagement_Score__c.toString(); + input.rollupFieldOnOpObject = ParentApplication__c.Engagement_Rollup__c.toString(); input.rollupOperation = 'AVERAGE'; - input.rollupSObjectName = ParentApplication__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(); - input.calcItemWhereClause = - Application__c.Something_With_Underscores__c.getDescribe().getName() + - ' != \'' + - applications[0].Something_With_Underscores__c + - '\''; + input.rollupSObjectName = ParentApplication__c.SObjectType.toString(); + input.calcItemWhereClause = Application__c.Something_With_Underscores__c.toString() + ' != \'' + applications[0].Something_With_Underscores__c + '\''; Test.startTest(); Rollup.performRollup(new List{ input }); @@ -188,16 +184,16 @@ private class RollupIntegrationTests { insert apps; Rollup.FlowInput input = new Rollup.FlowInput(); - input.lookupFieldOnCalcItem = Application__c.ParentApplication__c.getDescribe().getName(); + input.lookupFieldOnCalcItem = Application__c.ParentApplication__c.toString(); input.lookupFieldOnOpObject = 'Id'; input.recordsToRollup = new List{ parentApp }; input.rollupContext = 'INSERT'; - input.rollupFieldOnCalcItem = Application__c.Engagement_Score__c.getDescribe().getName(); - input.rollupFieldOnOpObject = ParentApplication__c.Engagement_Rollup__c.getDescribe().getName(); + input.rollupFieldOnCalcItem = Application__c.Engagement_Score__c.toString(); + input.rollupFieldOnOpObject = ParentApplication__c.Engagement_Rollup__c.toString(); input.rollupOperation = 'SUM'; - input.rollupSObjectName = ParentApplication__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(); + input.rollupSObjectName = ParentApplication__c.SObjectType.toString(); input.isRollupStartedFromParent = true; - input.calcItemTypeWhenRollupStartedFromParent = Application__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(); + input.calcItemTypeWhenRollupStartedFromParent = Application__c.SObjectType.toString(); Test.startTest(); Rollup.performRollup(new List{ input }); @@ -283,9 +279,9 @@ private class RollupIntegrationTests { Rollup.records = appLogs; Rollup.rollupMetadata = new List{ new Rollup__mdt( - CalcItem__c = ApplicationLog__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(), - RollupFieldOnCalcItem__c = ApplicationLog__c.Object__c.getDescribe().getName(), - LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.getDescribe().getName(), + CalcItem__c = ApplicationLog__c.SObjectType.toString(), + RollupFieldOnCalcItem__c = ApplicationLog__c.Object__c.toString(), + LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.toString(), LookupObject__c = 'Account', LookupFieldOnLookupObject__c = 'Id', RollupFieldOnLookupObject__c = 'Name', @@ -411,9 +407,9 @@ private class RollupIntegrationTests { Rollup.shouldFlattenAsyncProcesses = true; Rollup.rollupMetadata = new List{ new Rollup__mdt( - CalcItem__c = ApplicationLog__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(), + CalcItem__c = ApplicationLog__c.SObjectType.toString(), RollupFieldOnCalcItem__c = 'Name', - LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.getDescribe().getName(), + LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.toString(), LookupObject__c = 'Account', LookupFieldOnLookupObject__c = 'Id', RollupFieldOnLookupObject__c = 'Name', @@ -464,9 +460,9 @@ private class RollupIntegrationTests { Rollup.shouldFlattenAsyncProcesses = true; Rollup.rollupMetadata = new List{ new Rollup__mdt( - CalcItem__c = ApplicationLog__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(), + CalcItem__c = ApplicationLog__c.SObjectType.toString(), RollupFieldOnCalcItem__c = 'Name', - LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.getDescribe().getName(), + LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.toString(), LookupObject__c = 'Account', LookupFieldOnLookupObject__c = 'Id', RollupFieldOnLookupObject__c = 'Name', @@ -534,9 +530,9 @@ private class RollupIntegrationTests { Rollup.rollupMetadata = new List{ new Rollup__mdt( - CalcItem__c = ApplicationLog__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(), + CalcItem__c = ApplicationLog__c.SObjectType.toString(), RollupFieldOnCalcItem__c = 'Name', - LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.getDescribe().getName(), + LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.toString(), LookupObject__c = 'Account', LookupFieldOnLookupObject__c = 'Id', RollupFieldOnLookupObject__c = 'Name', @@ -584,9 +580,9 @@ private class RollupIntegrationTests { Rollup.shouldRun = true; Rollup.FlowInput input = new Rollup.FlowInput(); input.recordsToRollup = parentApps; - input.calcItemTypeWhenRollupStartedFromParent = ApplicationLog__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(); - input.rollupFieldOnCalcItem = ApplicationLog__c.Name.getDescribe().getName(); - input.lookupFieldOnCalcItem = ApplicationLog__c.Application__c.getDescribe().getName(); + input.calcItemTypeWhenRollupStartedFromParent = ApplicationLog__c.SObjectType.toString(); + input.rollupFieldOnCalcItem = ApplicationLog__c.Name.toString(); + input.lookupFieldOnCalcItem = ApplicationLog__c.Application__c.toString(); input.rollupSObjectName = 'Account'; input.lookupFieldOnOpObject = 'Id'; input.rollupFieldOnOpObject = 'Name'; @@ -638,9 +634,9 @@ private class RollupIntegrationTests { Rollup.records = appLogs; Rollup.rollupMetadata = new List{ new Rollup__mdt( - CalcItem__c = ApplicationLog__c.getSObjectType().getDescribe().getName(), - RollupFieldOnCalcItem__c = ApplicationLog__c.Name.getDescribe().getName(), - LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.getDescribe().getName(), + CalcItem__c = ApplicationLog__c.getSObjectType().toString(), + RollupFieldOnCalcItem__c = ApplicationLog__c.Name.toString(), + LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.toString(), LookupObject__c = 'Account', LookupFieldOnLookupObject__c = 'Id', RollupFieldOnLookupObject__c = 'Name', @@ -683,9 +679,9 @@ private class RollupIntegrationTests { Rollup.shouldFlattenAsyncProcesses = true; Rollup.rollupMetadata = new List{ new Rollup__mdt( - CalcItem__c = ApplicationLog__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(), + CalcItem__c = ApplicationLog__c.SObjectType.toString(), RollupFieldOnCalcItem__c = 'Name', - LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.getDescribe().getName(), + LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.toString(), LookupObject__c = 'Account', LookupFieldOnLookupObject__c = 'Id', RollupFieldOnLookupObject__c = 'AnnualRevenue', @@ -925,7 +921,7 @@ private class RollupIntegrationTests { null, new Rollup__mdt( RollupOperation__c = Rollup.Op.UPDATE_CONCAT_DISTINCT.name(), - RollupFieldOnCalcItem__c = Opportunity.AmountFormula__c.getDescribe().getName(), + RollupFieldOnCalcItem__c = Opportunity.AmountFormula__c.toString(), LookupFieldOnCalcItem__c = 'AccountId' ), new Map(), @@ -940,7 +936,7 @@ private class RollupIntegrationTests { null, new Rollup__mdt( RollupOperation__c = Rollup.Op.UPDATE_CONCAT_DISTINCT.name(), - RollupFieldOnCalcItem__c = Opportunity.AmountFormula__c.getDescribe().getName(), + RollupFieldOnCalcItem__c = Opportunity.AmountFormula__c.toString(), LookupFieldOnCalcItem__c = 'AccountId' ), new Map(), diff --git a/extra-tests/classes/RollupQueryBuilderTests.cls b/extra-tests/classes/RollupQueryBuilderTests.cls index ea5ca498..4aab8c87 100644 --- a/extra-tests/classes/RollupQueryBuilderTests.cls +++ b/extra-tests/classes/RollupQueryBuilderTests.cls @@ -57,7 +57,7 @@ private class RollupQueryBuilderTests { String queryString = RollupQueryBuilder.Current.getQuery( Event.SObjectType, new List{ 'Subject', 'WhatId' }, - Event.WhatId.getDescribe().getName(), + Event.WhatId.toString(), '!=', '(((What.Type = \'Account\') AND What.Owner.Id = :recordIds))' ); @@ -81,7 +81,7 @@ private class RollupQueryBuilderTests { String queryString = RollupQueryBuilder.Current.getQuery( Event.SObjectType, new List{ 'Subject', 'WhatId' }, - Event.WhatId.getDescribe().getName(), + Event.WhatId.toString(), '!=', '(((What.Type = \'Account\') OR What.Owner.Id = :recordIds))' ); @@ -98,7 +98,7 @@ private class RollupQueryBuilderTests { String queryString = RollupQueryBuilder.Current.getQuery( Opportunity.SObjectType, new List{ 'Amount' }, - Opportunity.AccountId.getDescribe().getName(), + Opportunity.AccountId.toString(), '=', 'Amount > 0 OR CloseDate = YESTERDAY' ); @@ -108,7 +108,7 @@ private class RollupQueryBuilderTests { @IsTest static void correctlyPutsAllRowsAtEnd() { String queryString = - RollupQueryBuilder.Current.getQuery(Event.SObjectType, new List{ 'Subject', 'WhatId' }, Event.WhatId.getDescribe().getName(), '!=') + '\nLIMIT 1'; + RollupQueryBuilder.Current.getQuery(Event.SObjectType, new List{ 'Subject', 'WhatId' }, Event.WhatId.toString(), '!=') + '\nLIMIT 1'; System.assertEquals(true, queryString.contains(RollupQueryBuilder.ALL_ROWS), 'Needs to have all rows in order to be valid'); queryString = RollupQueryBuilder.Current.getAllRowSafeQuery(Event.SObjectType, queryString); diff --git a/extra-tests/classes/RollupStateTests.cls b/extra-tests/classes/RollupStateTests.cls index d0bf0ef5..8b02d8a6 100644 --- a/extra-tests/classes/RollupStateTests.cls +++ b/extra-tests/classes/RollupStateTests.cls @@ -10,7 +10,6 @@ private class RollupStateTests { RollupState.GenericInfo.class ); info.value = 5; - RollupState.AverageInfo averageInfo = (RollupState.AverageInfo) state.getState( stubAccountId, new Rollup__mdt(RollupOperation__c = 'CONCAT'), @@ -32,17 +31,14 @@ private class RollupStateTests { mostInfo.setValues(5, 'some string'); // populate a null state value to be sure if the last iteration is "empty" the body is still properly committed state.getState(secondStubId, new Rollup__mdt(RollupOperation__c = 'LAST'), RollupState.GenericInfo.class); - Id stubJobId = RollupTestUtils.createId(AsyncApexJob.SObjectType); - Set relatedRecordKeys = new Set{ '%' + stubAccountId + '%', '%' + secondStubId + '%' }; - Test.startTest(); + state.commitState(stubJobId); state.loadState(stubJobId, new Set{ stubAccountId, secondStubId }); info = (RollupState.GenericInfo) state.getState(stubAccountId, new Rollup__mdt(RollupOperation__c = 'SUM'), RollupState.GenericInfo.class); info.value = 6; state.commitState(stubJobId); - Test.stopTest(); RollupState__c insertedState = [ SELECT Id, Body0__c @@ -188,9 +184,10 @@ private class RollupStateTests { List fieldKeys9 = new List(); List fieldKeys10 = new List(); List secondFieldKeys0 = new List(); - // 255 / 18 characters ~= 13 records per field (accounting for commas) String firstAccountId = RollupTestUtils.createId(Account.SObjectType) + 'aaa'; - for (Integer index = 0; index < 17 * 15; index++) { + // 255 / 18 characters ~= 13 records per field (accounting for commas) + // 12 because with 11 fields, we want to "overflow" to the second RelatedRecordKeys0__c + for (Integer index = 0; index < 13 * 12; index++) { String stubAccountId = index == 0 ? firstAccountId : RollupTestUtils.createId(Account.SObjectType) + 'aaa'; RollupState.GenericInfo info = (RollupState.GenericInfo) state.getState(stubAccountId, template, RollupState.GenericInfo.class); info.value = index; @@ -241,6 +238,7 @@ private class RollupStateTests { RelatedRecordKeys9__c, RelatedRecordKeys10__c FROM RollupState__c + WHERE RelatedJobId__c = :stubJobId ]; // ensure that loadState can be called with the full spread of keys state.loadState(stubJobId, fullKeys); @@ -265,6 +263,7 @@ private class RollupStateTests { Assert.isNotNull(firstState.RelatedRecordKeys8__c, 'RelatedRecordKeys8__c should have been filled out'); Assert.isNotNull(firstState.RelatedRecordKeys9__c, 'RelatedRecordKeys9__c should have been filled out'); Assert.isNotNull(firstState.RelatedRecordKeys10__c, 'RelatedRecordKeys10__c should have been filled out'); + Assert.isNotNull(secondState.RelatedRecordKeys0__c, 'Second RelatedRecordKeys0__c should have been filled out'); Assert.areEqual(String.join(fieldKeys0, ','), firstState.RelatedRecordKeys0__c, 'fieldKeys0'); Assert.areEqual(String.join(fieldKeys1, ','), firstState.RelatedRecordKeys1__c, 'fieldKeys1'); diff --git a/extra-tests/classes/RollupTestUtils.cls b/extra-tests/classes/RollupTestUtils.cls index d5e72649..5de73bf7 100644 --- a/extra-tests/classes/RollupTestUtils.cls +++ b/extra-tests/classes/RollupTestUtils.cls @@ -14,12 +14,12 @@ public class RollupTestUtils { Rollup.FlowInput flowInput = new Rollup.FlowInput(); flowInput.recordsToRollup = records; - flowInput.lookupFieldOnCalcItem = ContactPointAddress.ParentId.getDescribe().getName(); - flowInput.lookupFieldOnOpObject = Account.Id.getDescribe().getName(); + flowInput.lookupFieldOnCalcItem = ContactPointAddress.ParentId.toString(); + flowInput.lookupFieldOnOpObject = Account.Id.toString(); flowInput.rollupContext = rollupContext; - flowInput.rollupFieldOnCalcItem = ContactPointAddress.PreferenceRank.getDescribe().getName(); - flowInput.rollupFieldOnOpObject = Account.AnnualRevenue.getDescribe().getName(); - flowInput.rollupSObjectName = Account.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(); + flowInput.rollupFieldOnCalcItem = ContactPointAddress.PreferenceRank.toString(); + flowInput.rollupFieldOnOpObject = Account.AnnualRevenue.toString(); + flowInput.rollupSObjectName = Account.SObjectType.toString(); flowInput.rollupOperation = rollupOperation; flowInput.splitConcatDelimiterOnCalcItem = false; @@ -93,7 +93,7 @@ public class RollupTestUtils { String currencyIscoCodeFieldName = RollupCurrencyInfo.CURRENCY_ISO_CODE_FIELD_NAME; Set fieldNames = new Set(); for (Schema.SObjectField fieldToken : fieldTokens) { - fieldNames.add(fieldToken.getDescribe().getName()); + fieldNames.add(fieldToken.toString()); } if (fieldNames.contains('Name') == false) { diff --git a/extra-tests/classes/RollupTests.cls b/extra-tests/classes/RollupTests.cls index 9c956392..88c8d191 100644 --- a/extra-tests/classes/RollupTests.cls +++ b/extra-tests/classes/RollupTests.cls @@ -2996,8 +2996,8 @@ private class RollupTests { static void encapsulatesNamespaceInfoProperly() { Rollup.NamespaceInfo namespaceInfo = Rollup.getNamespaceInfo(); - String rollupObjectName = Rollup__mdt.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(); - System.assertEquals(rollupObjectName + '.' + Rollup__mdt.RollupOperation__c.getDescribe().getName(), nameSpaceInfo.safeRollupOperationField); + String rollupObjectName = Rollup__mdt.SObjectType.toString(); + System.assertEquals(rollupObjectName + '.' + Rollup__mdt.RollupOperation__c.toString(), nameSpaceInfo.safeRollupOperationField); System.assertEquals(rollupObjectName, nameSpaceInfo.safeObjectName); System.assertEquals(Rollup.class.getName() == 'Rollup' ? '' : Rollup.class.getName().substringBefore('.Rollup') + '__', nameSpaceInfo.namespace); } diff --git a/plugins/RollupCallback/README.md b/plugins/RollupCallback/README.md index d0776202..1aac5a22 100644 --- a/plugins/RollupCallback/README.md +++ b/plugins/RollupCallback/README.md @@ -104,7 +104,7 @@ public class SubflowRollupDispatcher implements RollupSObjectUpdater.IDispatcher List wrappedRecords = new List(); for (SObject record : records) { SObjectDecorator decorator = new SObjectDecorator(); - decorator.SObjectName = record.getSObjectType().getDescribe().getName(); + decorator.SObjectName = record.getSObjectType().toString(); decorator.RecordId = record.Id; decorator.FieldNames = new List(record.getPopulatedFieldsAsMap().keySet()); wrappedRecords.add(decorator); diff --git a/rollup/app/applications/Rollup.app-meta.xml b/rollup/app/applications/Rollup.app-meta.xml index 66171b3d..d06e01a3 100644 --- a/rollup/app/applications/Rollup.app-meta.xml +++ b/rollup/app/applications/Rollup.app-meta.xml @@ -16,5 +16,6 @@ Standard Recalculate_Rollup + RollupState__c Lightning diff --git a/rollup/app/tabs/RollupState__c.tab-meta.xml b/rollup/app/tabs/RollupState__c.tab-meta.xml new file mode 100644 index 00000000..56c13653 --- /dev/null +++ b/rollup/app/tabs/RollupState__c.tab-meta.xml @@ -0,0 +1,5 @@ + + + true + Custom78: Map + diff --git a/rollup/core/classes/Rollup.cls b/rollup/core/classes/Rollup.cls index a9e151b6..88159f73 100644 --- a/rollup/core/classes/Rollup.cls +++ b/rollup/core/classes/Rollup.cls @@ -376,14 +376,14 @@ global without sharing virtual class Rollup implements RollupLogger.ToStringObje } protected Rollup__mdt addOrderBys(Rollup__mdt localMeta, List orderBys, Schema.SObjectField calcItemRollupField) { - if (localMeta.RollupFieldOnCalcItem__c == calcItemRollupField.getDescribe().getName()) { + if (localMeta.RollupFieldOnCalcItem__c == calcItemRollupField.toString()) { localMeta = appendOrderByMetadata(localMeta, orderBys); } return localMeta; } protected void addLimitToMetadata(Rollup__mdt localMeta, Integer limitAmount, Schema.SObjectField calcItemRollupField) { - if (localMeta.RollupFieldOnCalcItem__c == calcItemRollupField.getDescribe().getName()) { + if (localMeta.RollupFieldOnCalcItem__c == calcItemRollupField.toString()) { localMeta.LimitAmount__c = limitAmount; localMeta.IsFullRecordSet__c = true; } @@ -482,9 +482,9 @@ global without sharing virtual class Rollup implements RollupLogger.ToStringObje public class NamespaceInfo { @AuraEnabled - public final String safeObjectName = Rollup__mdt.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(); + public final String safeObjectName = Rollup__mdt.SObjectType.toString(); @AuraEnabled - public final String safeRollupOperationField = this.safeObjectName + '.' + Rollup__mdt.RollupOperation__c.getDescribe().getName(); + public final String safeRollupOperationField = this.safeObjectName + '.' + Rollup__mdt.RollupOperation__c.toString(); @AuraEnabled public final String namespace = Rollup.class.getName() == 'Rollup' ? '' : Rollup.class.getName().substringBefore('.Rollup') + '__'; } @@ -1973,12 +1973,12 @@ global without sharing virtual class Rollup implements RollupLogger.ToStringObje List triggerRecords = getTriggerRecords(); Rollup__mdt meta = appendOrderByMetadata( new Rollup__mdt( - CalcItem__c = triggerRecords.getSObjectType()?.getDescribe().getName(), - LookupFieldOnCalcItem__c = lookupFieldOnCalcItem.getDescribe().getName(), - LookupFieldOnLookupObject__c = lookupFieldOnOperationObject.getDescribe().getName(), - LookupObject__c = lookupSObjectType.getDescribe().getName(), - RollupFieldOnCalcItem__c = operationFieldOnCalcItem.getDescribe().getName(), - RollupFieldOnLookupObject__c = operationFieldOnOperationObject.getDescribe().getName(), + CalcItem__c = triggerRecords.getSObjectType()?.toString(), + LookupFieldOnCalcItem__c = lookupFieldOnCalcItem.toString(), + LookupFieldOnLookupObject__c = lookupFieldOnOperationObject.toString(), + LookupObject__c = lookupSObjectType.toString(), + RollupFieldOnCalcItem__c = operationFieldOnCalcItem.toString(), + RollupFieldOnLookupObject__c = operationFieldOnOperationObject.toString(), RollupOperation__c = rollupOperation.name() ), orderByMetas @@ -2451,10 +2451,10 @@ global without sharing virtual class Rollup implements RollupLogger.ToStringObje String relationshipName = fieldToken.getDescribe().getRelationshipName(); Integer relationshipIndex = meta.GrandparentRelationshipFieldPath__c.indexOf(relationshipName) + relationshipName.length(); String priorFieldPath = meta.GrandparentRelationshipFieldPath__c.substring(0, relationshipIndex) + '.Id'; - if (meta.OneToManyGrandparentFields__c != null && meta.OneToManyGrandparentFields__c.contains(fieldToken.getDescribe().getName())) { + if (meta.OneToManyGrandparentFields__c != null && meta.OneToManyGrandparentFields__c.contains(fieldToken.toString())) { List fieldPathTuples = meta.OneToManyGrandparentFields__c.split(','); for (String fieldPathTuple : fieldPathTuples) { - if (fieldToken.getDescribe().getName().equalsIgnoreCase(fieldPathTuple.substringAfter('.'))) { + if (fieldToken.toString().equalsIgnoreCase(fieldPathTuple.substringAfter('.'))) { priorFieldPath = 'Id'; break; } @@ -2706,11 +2706,7 @@ global without sharing virtual class Rollup implements RollupLogger.ToStringObje for (Rollup__mdt rollupMetadata : rollupOperations) { Op rollupOp = OP_NAME_TO_OP.get(rollupMetadata.RollupOperation__c.toUpperCase()); - if ( - rollupMetadata.RollupGrouping__r.Id != null && - rollupMetadata.CalcItem__c != null && - rollupMetadata.CalcItem__c != sObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName() - ) { + if (rollupMetadata.RollupGrouping__r.Id != null && rollupMetadata.CalcItem__c != null && rollupMetadata.CalcItem__c != SObjectType.toString()) { Schema.DescribeSObjectResult childDescribe = init.getDescribeFromName(rollupMetadata.CalcItem__c); sObjectType = childDescribe.getSObjectType(); calcItemFields = childDescribe.fields.getMap(); diff --git a/rollup/core/classes/RollupAsyncProcessor.cls b/rollup/core/classes/RollupAsyncProcessor.cls index d4e9fa22..c2dd8285 100644 --- a/rollup/core/classes/RollupAsyncProcessor.cls +++ b/rollup/core/classes/RollupAsyncProcessor.cls @@ -303,7 +303,7 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme query = RollupQueryBuilder.Current.getQuery( firstRollup.lookupObj, new List(this.lookupObjectToUniqueFieldNames.get(firstRollup.lookupObj)), - firstRollup.lookupFieldOnLookupObject.getDescribe().getName(), + firstRollup.lookupFieldOnLookupObject.toString(), '=' ); } @@ -881,7 +881,7 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme } else if ( rollup.metadata?.RollupGrouping__r.Id != null && rollup.calcItems.isEmpty() == false && - rollup.calcItems[0].getSObjectType().getDescribe().getName() != rollup.metadata.CalcItem__c + rollup.calcItems[0].getSObjectType().toString() != rollup.metadata.CalcItem__c ) { List groupedProcessors = groupingToRollups.get(rollup.metadata?.RollupGrouping__r.Id) ?? new List(); groupedProcessors.add(rollup); @@ -1101,10 +1101,10 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme this.mapFields( this.lookupObjectToUniqueFieldNames, roll.lookupObj, - new Set{ roll.opFieldOnLookupObject.getDescribe().getName(), roll.lookupFieldOnLookupObject.getDescribe().getName() } + new Set{ roll.opFieldOnLookupObject.toString(), roll.lookupFieldOnLookupObject.toString() } ); - Set childFieldsToAdd = new Set{ roll.opFieldOnCalcItem.getDescribe().getName(), roll.lookupFieldOnCalcItem.getDescribe().getName() }; + Set childFieldsToAdd = new Set{ roll.opFieldOnCalcItem.toString(), roll.lookupFieldOnCalcItem.toString() }; if (String.isNotBlank(roll.metadata.CalcItemWhereClause__c)) { childFieldsToAdd.addAll(RollupEvaluator.getWhereEval(roll.metadata.CalcItemWhereClause__c, roll.calcItemType).getQueryFields()); } @@ -1166,7 +1166,7 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme for (Integer index = potentialRollups.size() - 1; index >= 0; index--) { RollupAsyncProcessor processor = potentialRollups[index]; Map fieldMap = processor.lookupObj?.getDescribe().fields.getMap(); - if (fieldMap?.containsKey(processor.opFieldOnLookupObject.getDescribe().getName()) == false) { + if (fieldMap?.containsKey(processor.opFieldOnLookupObject.toString()) == false) { potentialRollups.remove(index); } } @@ -1274,7 +1274,7 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme } for (SObject calcItem : roll.calcItems) { if (calcItem.getSObjectType() == roll.calcItemType) { - String lookupKey = (String) calcItem.get(roll.lookupFieldOnCalcItem.getDescribe().getName()); + String lookupKey = (String) calcItem.get(roll.lookupFieldOnCalcItem.toString()); if (String.isNotBlank(lookupKey)) { uniqueIds.add(lookupKey); } @@ -1378,8 +1378,8 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme if (priorLookup != calcItem.get(roll.lookupFieldOnCalcItem) && roll.traversal == null) { this.populateOldLookupItems(priorLookup, oldCalcItem, oldLookupItems); - } else if (roll.traversal?.isUltimatelyReparented(calcItem, roll.lookupFieldOnCalcItem.getDescribe().getName()) == true) { - Id oldLookupId = roll.traversal.getOldLookupId(calcItem, roll.lookupFieldOnCalcItem.getDescribe().getName()); + } else if (roll.traversal?.isUltimatelyReparented(calcItem, roll.lookupFieldOnCalcItem.toString()) == true) { + Id oldLookupId = roll.traversal.getOldLookupId(calcItem, roll.lookupFieldOnCalcItem.toString()); if (oldLookupId != null) { this.populateOldLookupItems(oldLookupId, oldCalcItem, oldLookupItems); } diff --git a/rollup/core/classes/RollupCalcItemReplacer.cls b/rollup/core/classes/RollupCalcItemReplacer.cls index 71ffa67f..03d5fc75 100644 --- a/rollup/core/classes/RollupCalcItemReplacer.cls +++ b/rollup/core/classes/RollupCalcItemReplacer.cls @@ -27,7 +27,7 @@ public without sharing class RollupCalcItemReplacer { if (fieldToken?.getDescribe().isCalculated() == false && fieldToken?.getDescribe().isUpdateable() == true) { target.put(fieldToken, value); } else { - target = serializeReplace(target, fieldToken.getDescribe().getName(), value); + target = serializeReplace(target, fieldToken.toString(), value); } return target; } @@ -76,7 +76,7 @@ public without sharing class RollupCalcItemReplacer { this.repo = this.repo ?? new RollupRepository(RollupMetaPicklists.getAccessLevel(metadata[0])); SObjectType calcType = calcItems[0].getSObjectType(); for (Rollup__mdt meta : metadata) { - if (meta.CalcItem__c != calcType.getDescribe().getName()) { + if (meta.CalcItem__c != calcType.toString()) { continue; } diff --git a/rollup/core/classes/RollupCalculator.cls b/rollup/core/classes/RollupCalculator.cls index 8d66a848..a0e14740 100644 --- a/rollup/core/classes/RollupCalculator.cls +++ b/rollup/core/classes/RollupCalculator.cls @@ -492,7 +492,7 @@ public without sharing abstract class RollupCalculator { public override void setDefaultValues(String lookupRecordKey, Object priorVal) { super.setDefaultValues(lookupRecordKey, priorVal); this.distinctValues = new Set(); - this.isIdCount = this.opFieldOnCalcItem.getDescribe().getName() == 'Id'; + this.isIdCount = this.opFieldOnCalcItem.toString() == 'Id'; Object defaultVal = RollupFieldInitializer.Current.getDefaultValue(opFieldOnLookupObject); if (defaultVal != 0 && this.returnVal != defaultVal && this.isIdCount == false) { this.distinctValues.add(this.returnVal); @@ -554,7 +554,7 @@ public without sharing abstract class RollupCalculator { } } else { List results = this.repo.get(); - String calcItemOpField = this.opFieldOnCalcItem.getDescribe().getName(); + String calcItemOpField = this.opFieldOnCalcItem.toString(); for (SObject res : results) { // have to use the String representation of the this.opFieldOnCalcItem to avoid: // System.SObjectException: SObject.FieldName does not belong to SObject type AggregateResult @@ -1098,7 +1098,7 @@ public without sharing abstract class RollupCalculator { .setQuery( RollupQueryBuilder.Current.getQuery( this.calcItemSObjectType, - new List{ this.opFieldOnCalcItem.getDescribe().getName() }, + new List{ this.opFieldOnCalcItem.toString() }, 'Id', '!=', this.lookupKeyQuery @@ -1482,7 +1482,7 @@ public without sharing abstract class RollupCalculator { String suffix = isLast ? this.trClose : ''; this.columnHeaders.add(prefix + this.thOpen + this.fieldNameToToken.get(fieldName).getDescribe().getLabel() + this.thClose); if (isLast) { - this.columnHeaders.add(this.thOpen + this.targetField.getDescribe().getName() + this.thClose + suffix); + this.columnHeaders.add(this.thOpen + this.targetField.toString() + this.thClose + suffix); } return prefix + this.tdOpen + String.valueOf(groupingValue) + this.tdClose + suffix; } diff --git a/rollup/core/classes/RollupCurrencyInfo.cls b/rollup/core/classes/RollupCurrencyInfo.cls index 285696fb..f5b7e41c 100644 --- a/rollup/core/classes/RollupCurrencyInfo.cls +++ b/rollup/core/classes/RollupCurrencyInfo.cls @@ -141,7 +141,7 @@ public without sharing virtual class RollupCurrencyInfo { return; } for (SObject calcItem : calcItems) { - if (DATED_MULTICURRENCY_SUPPORTED_OBJECTS.containsKey(calcItem.getSObjectType().getDescribe().getName()) == false) { + if (DATED_MULTICURRENCY_SUPPORTED_OBJECTS.containsKey(calcItem.getSObjectType().toString()) == false) { return; } Datetime currencyDate = getCurrencyDate(calcItem); @@ -234,7 +234,7 @@ public without sharing virtual class RollupCurrencyInfo { } private static String getHashKey(SObject calcItem, Schema.SObjectField opFieldOnCalcItem) { - return '' + calcItem.Id + opFieldOnCalcItem.getDescribe().getName() + calcItem.hashCode(); + return '' + calcItem.Id + opFieldOnCalcItem.toString() + calcItem.hashCode(); } private static Map getCurrencyMap() { @@ -264,7 +264,7 @@ public without sharing virtual class RollupCurrencyInfo { } private static Datetime getCurrencyDate(SObject calcItem) { - List itemToDateFieldMapping = DATED_MULTICURRENCY_SUPPORTED_OBJECTS.get(calcItem.getSObjectType().getDescribe().getName()); + List itemToDateFieldMapping = DATED_MULTICURRENCY_SUPPORTED_OBJECTS.get(calcItem.getSObjectType().toString()); switch on itemToDateFieldMapping?.size() { when 1 { return calcItem.isSet(itemToDateFieldMapping[0]) ? (Datetime) calcItem.get(itemToDateFieldMapping[0]) : null; diff --git a/rollup/core/classes/RollupFlowBulkProcessor.cls b/rollup/core/classes/RollupFlowBulkProcessor.cls index 67586677..ab7bff99 100644 --- a/rollup/core/classes/RollupFlowBulkProcessor.cls +++ b/rollup/core/classes/RollupFlowBulkProcessor.cls @@ -84,7 +84,7 @@ global without sharing class RollupFlowBulkProcessor { List rollupMetadata = Rollup.getMetadataFromCache(Rollup__mdt.SObjectType); // for some reason, lists passed from Flow to Apex report their SObjectType as null. womp. Schema.SObjectType sObjectType = flowInput.recordsToRollup?.get(0).getSObjectType(); - String childName = sObjectType?.getDescribe(SObjectDescribeOptions.DEFERRED).getName(); + String childName = sObjectType?.toString(); for (Rollup__mdt meta : rollupMetadata) { if ( meta.IsRollupStartedFromParent__c || diff --git a/rollup/core/classes/RollupFullRecalcProcessor.cls b/rollup/core/classes/RollupFullRecalcProcessor.cls index a64742d0..23d6fd18 100644 --- a/rollup/core/classes/RollupFullRecalcProcessor.cls +++ b/rollup/core/classes/RollupFullRecalcProcessor.cls @@ -123,7 +123,7 @@ global abstract without sharing class RollupFullRecalcProcessor extends RollupAs for (Rollup__mdt meta : this.rollupMetas) { Object defaultVal = this.getDefaultValue(meta); for (SObject parentRecordToReset : this.parentRecordsToClear.values()) { - if (parentRecordToReset.getSObjectType().getDescribe().getName() != meta.LookupObject__c) { + if (parentRecordToReset.getSObjectType().toString() != meta.LookupObject__c) { continue; } SObject relatedParentRecord = relatedParentRecordsMap.get(parentRecordToReset.Id); diff --git a/rollup/core/classes/RollupParentResetProcessor.cls b/rollup/core/classes/RollupParentResetProcessor.cls index 0e29ff70..e5b036f9 100644 --- a/rollup/core/classes/RollupParentResetProcessor.cls +++ b/rollup/core/classes/RollupParentResetProcessor.cls @@ -57,24 +57,24 @@ public without sharing class RollupParentResetProcessor extends RollupFullBatchR getRefinedQueryString(this.queryString, this.rollupMetas, this.invokePoint); this.objIds.addAll(this.recordIds); String processId = this.getNoProcessId(); - if (isValidRun == false || this.rollupControl.ShouldSkipResettingParentFields__c == true || this.countOfItems == 0) { + if (isValidRun == false || this.rollupControl.ShouldSkipResettingParentFields__c == true || this.countOfItems <= 0) { this.logger.log('Parent reset processor no-op', System.LoggingLevel.INFO); return processId; } Boolean isOverLimit = this.countOfItems > maxQueryRows; - if (isOverLimit && this.isBatch() == false) { - // avoids: System.AsyncException: Database.executeBatch cannot be called from a batch start, batch execute, or future method - processId = super.startAsyncWork(); - } else if (isOverLimit && Limits.getLimitQueueableJobs() > Limits.getQueueableJobs()) { + Integer previouslyQueuedJobs = Limits.getQueueableJobs(); + if (isOverLimit && System.isQueueable() && previouslyQueuedJobs == 1) { + this.finalizer.addCaboose(this); + } else if (isOverLimit && Limits.getLimitQueueableJobs() > previouslyQueuedJobs) { // avoids System.LimitException: Too many queueable jobs added to the queue: { output of Limits.getQueueableJobs() } // down the rabbit hole we go again processId = this.startAsyncWork(); } else if (this.countOfItems > 0) { + isRecursiveRun = true; for (RollupAsyncProcessor proc : this.rollups) { - isRecursiveRun = true; proc.runCalc(); - isRecursiveRun = false; } + isRecursiveRun = false; this.runSync(); } @@ -85,18 +85,18 @@ public without sharing class RollupParentResetProcessor extends RollupFullBatchR if (parentItems.isEmpty()) { return; } - this.logger.log('resetting parent fields for: ' + parentItems.size() + ' items', System.LoggingLevel.INFO); + this.logger.log('resetting parent fields for: ' + parentItems.size() + ' items', System.LoggingLevel.DEBUG); Map parentFields = parentItems.get(0).getSObjectType().getDescribe().fields.getMap(); for (Rollup__mdt rollupMeta : this.rollupMetas) { - Object defaultVal = this.getDefaultValue(rollupMeta); Schema.SObjectField parentFieldToken = parentFields.get(rollupMeta.RollupFieldOnLookupObject__c); if ( - rollupMeta.LookupObject__c != this.calcItemType.getDescribe().getName() || + rollupMeta.LookupObject__c != this.calcItemType.toString() || this.parentRollupFieldHasBeenReset(rollupMeta.LookupObject__c, rollupMeta.RollupFieldOnLookupObject__c) || parentFieldToken == null ) { continue; } + Object defaultVal = this.getDefaultValue(rollupMeta); for (SObject parentItem : parentItems) { this.getDML().updateField(parentFieldToken, parentItem, defaultVal); } diff --git a/rollup/core/classes/RollupRelationshipFieldFinder.cls b/rollup/core/classes/RollupRelationshipFieldFinder.cls index e124b0c3..7908a074 100644 --- a/rollup/core/classes/RollupRelationshipFieldFinder.cls +++ b/rollup/core/classes/RollupRelationshipFieldFinder.cls @@ -221,8 +221,8 @@ public without sharing class RollupRelationshipFieldFinder { // if we're only going one relationship up, we need to validate that the // parent's relationship name doesn't differ from its SObject name if (this.relationshipParts.size() == 1 && this.isFirstRun) { - SObjectField parentField = this.getField(baseSObjectType.getDescribe().fields.getMap(), this.ultimateParent.getDescribe().getName()); - this.relationshipParts.add(0, parentField.getDescribe().getName()); + SObjectField parentField = this.getField(baseSObjectType.getDescribe().fields.getMap(), this.ultimateParent.toString()); + this.relationshipParts.add(0, parentField.toString()); } if (baseSObjectType == this.ultimateParent && this.isFinishedWithHierarchyTraversal(records)) { @@ -259,11 +259,11 @@ public without sharing class RollupRelationshipFieldFinder { SObjectField field = fieldMap.get(key); if (field.getDescribe().getRelationshipName() == relationshipPart) { return field; - } else if (field.getDescribe().getName() == relationshipPart) { + } else if (field.toString() == relationshipPart) { return field; } else if (field.getDescribe().isNamePointing()) { for (SObjectType potentialMatch : field.getDescribe().getReferenceTo()) { - if (potentialMatch.getDescribe().getName() == relationshipPart) { + if (potentialMatch.toString() == relationshipPart) { return field; } } @@ -392,7 +392,7 @@ public without sharing class RollupRelationshipFieldFinder { this.populateHierarchicalLookupFields(fieldNames, this.getField(fieldMap, this.metadata.UltimateParentLookup__c)); } } else { - fieldNames.add(field.getDescribe().getName()); + fieldNames.add(field.toString()); } // NB - we only support one route through polymorphic fields such as Task.WhoId and Task.WhatId for this sort of thing @@ -542,8 +542,8 @@ public without sharing class RollupRelationshipFieldFinder { } List copiedFieldNamesPerRelationship = new List(queryFieldNames); String relationshipName = hierarchyToken.getDescribe().getRelationshipName(); - String hierarchyName = hierarchyToken.getDescribe().getName(); - queryFieldNames.add(hierarchyToken.getDescribe().getName()); + String hierarchyName = hierarchyToken.toString(); + queryFieldNames.add(hierarchyToken.toString()); for (Integer index = 0; index < MAX_FOREIGN_KEY_RELATIONSHIP_HOPS; index++) { String baseOfHierarchy = relationshipName.repeat(index).replace(relationshipName, relationshipName + '.'); String repeatedHierarchy = baseOfHierarchy + hierarchyName; @@ -780,7 +780,7 @@ public without sharing class RollupRelationshipFieldFinder { private String getChildRelationshipFromType(Schema.SObjectType sObjectType, String relationshipName) { for (Schema.ChildRelationship child : sObjectType.getDescribe(SObjectDescribeOptions.FULL).getChildRelationships()) { if (child.getRelationshipName() == relationshipName) { - return child.getChildSObject().getDescribe().getName(); + return child.getChildSObject().toString(); } } return null; diff --git a/rollup/core/classes/RollupState.cls b/rollup/core/classes/RollupState.cls index ea77dc1a..b816db5f 100644 --- a/rollup/core/classes/RollupState.cls +++ b/rollup/core/classes/RollupState.cls @@ -35,6 +35,9 @@ public without sharing virtual class RollupState implements System.Queueable, Sy if (possibleState == null) { possibleState = (RollupState) initializingType.newInstance(); possibleState.recordId = key; + // we only pass the original key's length because even though state is keyed by the trueKey + // the original key's length gives us access to the record key when committing state values to the + // various RelatedRecordKey{n}__c fields this.setState(trueKey, key.length(), possibleState); } return possibleState; @@ -189,14 +192,14 @@ public without sharing virtual class RollupState implements System.Queueable, Sy SELECT Id FROM RollupState__c WHERE RelatedJobId__c = :this.jobIds - LIMIT :(Limits.getLimitDmlRows() - (Limits.getDmlRows() + 1)) + LIMIT :Limits.getLimitDmlRows() - Limits.getDmlRows() ]; Database.delete(matchingState, false, System.AccessLevel.SYSTEM_MODE); } public void execute(System.FinalizerContext fc) { if ([SELECT COUNT() FROM RollupState__c WHERE Id = :this.jobIds LIMIT 1] > 0) { - new RollupState().cleanup(new Set(this.jobIds)); + new RollupState().cleanup(this.jobIds); } } diff --git a/rollup/core/objects/RollupState__c/RollupState__c.object-meta.xml b/rollup/core/objects/RollupState__c/RollupState__c.object-meta.xml index 0439b09f..03058b6a 100644 --- a/rollup/core/objects/RollupState__c/RollupState__c.object-meta.xml +++ b/rollup/core/objects/RollupState__c/RollupState__c.object-meta.xml @@ -1,117 +1,5 @@ - + - - Accept - Default - - - Accept - Large - Default - - - Accept - Small - Default - - - CancelEdit - Default - - - CancelEdit - Large - Default - - - CancelEdit - Small - Default - - - Clone - Default - - - Clone - Large - Default - - - Clone - Small - Default - - - Delete - Default - - - Delete - Large - Default - - - Delete - Small - Default - - - Edit - Default - - - Edit - Large - Default - - - Edit - Small - Default - - - List - Default - - - List - Large - Default - - - List - Small - Default - - - New - Default - - - New - Large - Default - - - New - Small - Default - - - SaveEdit - Default - - - SaveEdit - Large - Default - - - SaveEdit - Small - Default - Tab Default @@ -155,10 +43,11 @@ false false false - false - false + true + true true true + Private RS-{00000000} @@ -166,7 +55,7 @@ AutoNumber Rollup States - + ReadWrite Public diff --git a/rollup/core/objects/RollupState__c/fields/RelatedRecordKeys0__c.field-meta.xml b/rollup/core/objects/RollupState__c/fields/RelatedRecordKeys0__c.field-meta.xml index 854d5ebb..8d67e643 100644 --- a/rollup/core/objects/RollupState__c/fields/RelatedRecordKeys0__c.field-meta.xml +++ b/rollup/core/objects/RollupState__c/fields/RelatedRecordKeys0__c.field-meta.xml @@ -1,9 +1,9 @@ RelatedRecordKeys0__c - Comma separated list of parent records with any rollup state associated with them - - Comma separated list of parent records with any rollup state associated with them + Comma separated list of parent records with any rollup state associated with them 0 + + Comma separated list of parent records with any rollup state associated with them 0 false 255 false diff --git a/rollup/core/objects/RollupState__c/fields/RelatedRecordKeys2__c.field-meta.xml b/rollup/core/objects/RollupState__c/fields/RelatedRecordKeys2__c.field-meta.xml index 77ce8c66..b968da1e 100644 --- a/rollup/core/objects/RollupState__c/fields/RelatedRecordKeys2__c.field-meta.xml +++ b/rollup/core/objects/RollupState__c/fields/RelatedRecordKeys2__c.field-meta.xml @@ -2,7 +2,7 @@ RelatedRecordKeys2__c Comma separated list of parent records with any rollup state associated with them 2 - + Comma separated list of parent records with any rollup state associated with them 2 false 255 diff --git a/rollup/core/objects/RollupState__c/listViews/All.listView-meta.xml b/rollup/core/objects/RollupState__c/listViews/All.listView-meta.xml new file mode 100644 index 00000000..eabf3e70 --- /dev/null +++ b/rollup/core/objects/RollupState__c/listViews/All.listView-meta.xml @@ -0,0 +1,21 @@ + + + All + NAME + RelatedJobId__c + RelatedRecordKeys0__c + RelatedRecordKeys1__c + RelatedRecordKeys2__c + RelatedRecordKeys3__c + RelatedRecordKeys4__c + RelatedRecordKeys5__c + RelatedRecordKeys6__c + RelatedRecordKeys7__c + RelatedRecordKeys8__c + RelatedRecordKeys9__c + RelatedRecordKeys10__c + CREATED_DATE + CREATEDBY_USER + Everything + + diff --git a/rollup/core/objects/RollupState__c/listViews/MyRollupStates.listView-meta.xml b/rollup/core/objects/RollupState__c/listViews/MyRollupStates.listView-meta.xml new file mode 100644 index 00000000..3d18fd74 --- /dev/null +++ b/rollup/core/objects/RollupState__c/listViews/MyRollupStates.listView-meta.xml @@ -0,0 +1,21 @@ + + + MyRollupStates + NAME + RelatedJobId__c + RelatedRecordKeys0__c + RelatedRecordKeys1__c + RelatedRecordKeys2__c + RelatedRecordKeys3__c + RelatedRecordKeys4__c + RelatedRecordKeys5__c + RelatedRecordKeys6__c + RelatedRecordKeys7__c + RelatedRecordKeys8__c + RelatedRecordKeys9__c + RelatedRecordKeys10__c + CREATED_DATE + CREATEDBY_USER + Mine + + diff --git a/rollup/core/profiles/Admin.profile-meta.xml b/rollup/core/profiles/Admin.profile-meta.xml index 9780dd76..5f99e8b2 100644 --- a/rollup/core/profiles/Admin.profile-meta.xml +++ b/rollup/core/profiles/Admin.profile-meta.xml @@ -105,6 +105,71 @@ true RollupPluginParameter__mdt + + true + RollupState__c.Body0__c + true + + + true + RollupState__c.RelatedJobId__c + true + + + true + RollupState__c.RelatedRecordKeys0__c + true + + + true + RollupState__c.RelatedRecordKeys1__c + true + + + true + RollupState__c.RelatedRecordKeys2__c + true + + + true + RollupState__c.RelatedRecordKeys3__c + true + + + true + RollupState__c.RelatedRecordKeys4__c + true + + + true + RollupState__c.RelatedRecordKeys5__c + true + + + true + RollupState__c.RelatedRecordKeys6__c + true + + + true + RollupState__c.RelatedRecordKeys7__c + true + + + true + RollupState__c.RelatedRecordKeys8__c + true + + + true + RollupState__c.RelatedRecordKeys9__c + true + + + true + RollupState__c.RelatedRecordKeys10__c + true + RollupControl__mdt-Rollup Control Layout @@ -120,5 +185,14 @@ RollupPluginParameter__mdt-Rollup Plugin Parameter Layout + + true + true + true + true + true + RollupState__c + true + Salesforce diff --git a/scripts/convert-dlrs-rules-namespaced.apex b/scripts/convert-dlrs-rules-namespaced.apex index fa035ae1..d82fede3 100644 --- a/scripts/convert-dlrs-rules-namespaced.apex +++ b/scripts/convert-dlrs-rules-namespaced.apex @@ -4,14 +4,10 @@ static final please__RollupControl__mdt ROLLUP_CONTROL = please__RollupControl__mdt.getInstance('please__Org_Defaults'); // Prepare the converted Rollup__mdt CMDT records for deployment -String customMetadataTypePrefix = Schema.please__Rollup__mdt.SObjectType.getDescribe().getName().replace('__mdt', ''); +String customMetadataTypePrefix = Schema.please__Rollup__mdt.SObjectType.toString().replace('__mdt', ''); Metadata.DeployContainer deployment = new Metadata.DeployContainer(); -Set objectsUnsupportedUsingEntityDefinition = new Set{ - Event.SObjectType.getDescribe().getName(), - Task.SObjectType.getDescribe().getName(), - User.SObjectType.getDescribe().getName() -}; +Set objectsUnsupportedUsingEntityDefinition = new Set{ Event.SObjectType.toString(), Task.SObjectType.toString(), User.SObjectType.toString() }; Boolean shouldDeploy = false; for (dlrs__LookupRollupSummary2__mdt dlrsRule : dlrs__LookupRollupSummary2__mdt.getAll().values()) { @@ -65,20 +61,20 @@ for (dlrs__LookupRollupSummary2__mdt dlrsRule : dlrs__LookupRollupSummary2__mdt. // This code uses instances of Metadata.CustomMetadataValue for the deployment - not instances of Rollup__mdt // So, use a map & field tokens to store the expected values - Salesforce will store the data as Rollup__mdt records when deployed Map fieldValuesToCopy = new Map{ - calcObject.getDescribe().getName() => dlrsRule.dlrs__ChildObject__c, - please__Rollup__mdt.please__CalcItemWhereClause__c.getDescribe().getName() => dlrsRule.dlrs__RelationshipCriteria__c, - please__Rollup__mdt.please__ConcatDelimiter__c.getDescribe().getName() => operation.startsWith('CONCAT') ? dlrsRule.dlrs__ConcatenateDelimiter__c : null, - please__Rollup__mdt.please__Description__c.getDescribe().getName() => dlrsRule.dlrs__Description__c, - please__Rollup__mdt.please__LimitAmount__c.getDescribe().getName() => dlrsRule.dlrs__RowLimit__c, - lookupFieldCalcItem.getDescribe().getName() => dlrsRule.dlrs__RelationshipField__c, - lookupFieldParent.getDescribe().getName() => 'Id', - lookupObject.getDescribe().getName() => dlrsRule.dlrs__ParentObject__c, - please__Rollup__mdt.please__OrderByFirstLast__c.getDescribe().getName() => dlrsRule.dlrs__FieldToOrderBy__c, - please__Rollup__mdt.please__RollupControl__c.getDescribe().getName() => ROLLUP_CONTROL.DeveloperName, - rollupFieldCalcItem.getDescribe().getName() => dlrsRule.dlrs__FieldToAggregate__c, - rollupFieldParent.getDescribe().getName() => dlrsRule.dlrs__AggregateResultField__c, - please__Rollup__mdt.please__RollupOperation__c.getDescribe().getName() => operation.toUpperCase(), - please__Rollup__mdt.please__SharingMode__c.getDescribe().getName() => dlrsRule.dlrs__CalculationSharingMode__c + calcObject.toString() => dlrsRule.dlrs__ChildObject__c, + please__Rollup__mdt.please__CalcItemWhereClause__c.toString() => dlrsRule.dlrs__RelationshipCriteria__c, + please__Rollup__mdt.please__ConcatDelimiter__c.toString() => operation.startsWith('CONCAT') ? dlrsRule.dlrs__ConcatenateDelimiter__c : null, + please__Rollup__mdt.please__Description__c.toString() => dlrsRule.dlrs__Description__c, + please__Rollup__mdt.please__LimitAmount__c.toString() => dlrsRule.dlrs__RowLimit__c, + lookupFieldCalcItem.toString() => dlrsRule.dlrs__RelationshipField__c, + lookupFieldParent.toString() => 'Id', + lookupObject.toString() => dlrsRule.dlrs__ParentObject__c, + please__Rollup__mdt.please__OrderByFirstLast__c.toString() => dlrsRule.dlrs__FieldToOrderBy__c, + please__Rollup__mdt.please__RollupControl__c.toString() => ROLLUP_CONTROL.DeveloperName, + rollupFieldCalcItem.toString() => dlrsRule.dlrs__FieldToAggregate__c, + rollupFieldParent.toString() => dlrsRule.dlrs__AggregateResultField__c, + please__Rollup__mdt.please__RollupOperation__c.toString() => operation.toUpperCase(), + please__Rollup__mdt.please__SharingMode__c.toString() => dlrsRule.dlrs__CalculationSharingMode__c // Additional DLRS fields that are not supported/used by Rollup // dlrs__AggregateAllRows__c @@ -90,7 +86,7 @@ for (dlrs__LookupRollupSummary2__mdt dlrsRule : dlrs__LookupRollupSummary2__mdt. for (String fieldName : fieldValuesToCopy.keySet()) { Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue(); customField.field = fieldName; - if (fieldName == please__Rollup__mdt.please__Description__c.getDescribe().getName()) { + if (fieldName == please__Rollup__mdt.please__Description__c.toString()) { customField.value = 'Generated by migration script:\n' + fieldValuesToCopy.get(fieldName); } else { customField.value = fieldValuesToCopy.get(fieldName); diff --git a/scripts/convert-dlrs-rules.apex b/scripts/convert-dlrs-rules.apex index 08e4e4eb..ecda53b4 100644 --- a/scripts/convert-dlrs-rules.apex +++ b/scripts/convert-dlrs-rules.apex @@ -4,7 +4,7 @@ static final RollupControl__mdt ROLLUP_CONTROL = RollupControl__mdt.getInstance('Org_Defaults'); // Prepare the converted Rollup__mdt CMDT records for deployment -String customMetadataTypePrefix = Schema.Rollup__mdt.SObjectType.getDescribe().getName().replace('__mdt', ''); +String customMetadataTypePrefix = Schema.Rollup__mdt.SObjectType.toString().replace('__mdt', ''); Metadata.DeployContainer deployment = new Metadata.DeployContainer(); List objectsUnsupportedUsingEntityDefinition = new List{ 'Event', 'Task', 'User' }; @@ -61,20 +61,20 @@ for (dlrs__LookupRollupSummary2__mdt dlrsRule : dlrs__LookupRollupSummary2__mdt. // This code uses instances of Metadata.CustomMetadataValue for the deployment - not instances of Rollup__mdt // So, use a map & field tokens to store the expected values - Salesforce will store the data as Rollup__mdt records when deployed Map fieldValuesToCopy = new Map{ - calcObject.getDescribe().getName() => dlrsRule.dlrs__ChildObject__c, - Schema.Rollup__mdt.CalcItemWhereClause__c.getDescribe().getName() => dlrsRule.dlrs__RelationshipCriteria__c, - Schema.Rollup__mdt.ConcatDelimiter__c.getDescribe().getName() => operation.startsWith('CONCAT') ? dlrsRule.dlrs__ConcatenateDelimiter__c : null, - Schema.Rollup__mdt.Description__c.getDescribe().getName() => dlrsRule.dlrs__Description__c, - Schema.Rollup__mdt.LimitAmount__c.getDescribe().getName() => dlrsRule.dlrs__RowLimit__c, - lookupFieldCalcItem.getDescribe().getName() => dlrsRule.dlrs__RelationshipField__c, - lookupFieldParent.getDescribe().getName() => 'Id', - lookupObject.getDescribe().getName() => dlrsRule.dlrs__ParentObject__c, - Schema.Rollup__mdt.OrderByFirstLast__c.getDescribe().getName() => dlrsRule.dlrs__FieldToOrderBy__c, - Schema.Rollup__mdt.RollupControl__c.getDescribe().getName() => ROLLUP_CONTROL.DeveloperName, - rollupFieldCalcItem.getDescribe().getName() => dlrsRule.dlrs__FieldToAggregate__c, - rollupFieldParent.getDescribe().getName() => dlrsRule.dlrs__AggregateResultField__c, - Schema.Rollup__mdt.RollupOperation__c.getDescribe().getName() => operation.toUpperCase(), - Schema.Rollup__mdt.SharingMode__c.getDescribe().getName() => dlrsRule.dlrs__CalculationSharingMode__c + calcObject.toString() => dlrsRule.dlrs__ChildObject__c, + Schema.Rollup__mdt.CalcItemWhereClause__c.toString() => dlrsRule.dlrs__RelationshipCriteria__c, + Schema.Rollup__mdt.ConcatDelimiter__c.toString() => operation.startsWith('CONCAT') ? dlrsRule.dlrs__ConcatenateDelimiter__c : null, + Schema.Rollup__mdt.Description__c.toString() => dlrsRule.dlrs__Description__c, + Schema.Rollup__mdt.LimitAmount__c.toString() => dlrsRule.dlrs__RowLimit__c, + lookupFieldCalcItem.toString() => dlrsRule.dlrs__RelationshipField__c, + lookupFieldParent.toString() => 'Id', + lookupObject.toString() => dlrsRule.dlrs__ParentObject__c, + Schema.Rollup__mdt.OrderByFirstLast__c.toString() => dlrsRule.dlrs__FieldToOrderBy__c, + Schema.Rollup__mdt.RollupControl__c.toString() => ROLLUP_CONTROL.DeveloperName, + rollupFieldCalcItem.toString() => dlrsRule.dlrs__FieldToAggregate__c, + rollupFieldParent.toString() => dlrsRule.dlrs__AggregateResultField__c, + Schema.Rollup__mdt.RollupOperation__c.toString() => operation.toUpperCase(), + Schema.Rollup__mdt.SharingMode__c.toString() => dlrsRule.dlrs__CalculationSharingMode__c // Additional DLRS fields that are not supported/used by Rollup // dlrs__AggregateAllRows__c @@ -86,7 +86,7 @@ for (dlrs__LookupRollupSummary2__mdt dlrsRule : dlrs__LookupRollupSummary2__mdt. for (String fieldName : fieldValuesToCopy.keySet()) { Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue(); customField.field = fieldName; - if (fieldName == Schema.Rollup__mdt.Description__c.getDescribe().getName()) { + if (fieldName == Schema.Rollup__mdt.Description__c.toString()) { customField.value = 'Generated by migration script:\n' + fieldValuesToCopy.get(fieldName); } else { customField.value = fieldValuesToCopy.get(fieldName); diff --git a/scripts/deactivate-converted-dlrs-rules-namespaced.apex b/scripts/deactivate-converted-dlrs-rules-namespaced.apex index 899f1de9..779391da 100644 --- a/scripts/deactivate-converted-dlrs-rules-namespaced.apex +++ b/scripts/deactivate-converted-dlrs-rules-namespaced.apex @@ -2,7 +2,7 @@ // This assumes that the records in dlrs__LookupRollupSummary2__mdt and please__Rollup__mdt have the same DeveloperName Set rollupRecordDeveloperNames = please__Rollup__mdt.getAll().keySet(); -String dlrsCustomMetadataTypePrefix = Schema.dlrs__LookupRollupSummary2__mdt.SObjectType.getDescribe().getName().replace('__mdt', ''); +String dlrsCustomMetadataTypePrefix = Schema.dlrs__LookupRollupSummary2__mdt.SObjectType.toString().replace('__mdt', ''); Metadata.DeployContainer deployment = new Metadata.DeployContainer(); for (dlrs__LookupRollupSummary2__mdt dlrsRule : dlrs__LookupRollupSummary2__mdt.getAll().values()) { @@ -12,7 +12,7 @@ for (dlrs__LookupRollupSummary2__mdt dlrsRule : dlrs__LookupRollupSummary2__mdt. } Metadata.CustomMetadataValue dlrsIsActiveField = new Metadata.CustomMetadataValue(); - dlrsIsActiveField.field = Schema.dlrs__LookupRollupSummary2__mdt.dlrs__Active__c.getDescribe().getName(); + dlrsIsActiveField.field = Schema.dlrs__LookupRollupSummary2__mdt.dlrs__Active__c.toString(); dlrsIsActiveField.value = false; Metadata.CustomMetadata dlrsCustomMetadataRecord = new Metadata.CustomMetadata(); diff --git a/scripts/deactivate-converted-dlrs-rules.apex b/scripts/deactivate-converted-dlrs-rules.apex index 1b66eb01..6de8c281 100644 --- a/scripts/deactivate-converted-dlrs-rules.apex +++ b/scripts/deactivate-converted-dlrs-rules.apex @@ -2,7 +2,7 @@ // This assumes that the records in dlrs__LookupRollupSummary2__mdt and Rollup__mdt have the same DeveloperName Set rollupRecordDeveloperNames = Rollup__mdt.getAll().keySet(); -String dlrsCustomMetadataTypePrefix = Schema.dlrs__LookupRollupSummary2__mdt.SObjectType.getDescribe().getName().replace('__mdt', ''); +String dlrsCustomMetadataTypePrefix = Schema.dlrs__LookupRollupSummary2__mdt.SObjectType.toString().replace('__mdt', ''); Metadata.DeployContainer deployment = new Metadata.DeployContainer(); for (dlrs__LookupRollupSummary2__mdt dlrsRule : dlrs__LookupRollupSummary2__mdt.getAll().values()) { @@ -12,7 +12,7 @@ for (dlrs__LookupRollupSummary2__mdt dlrsRule : dlrs__LookupRollupSummary2__mdt. } Metadata.CustomMetadataValue dlrsIsActiveField = new Metadata.CustomMetadataValue(); - dlrsIsActiveField.field = Schema.dlrs__LookupRollupSummary2__mdt.dlrs__Active__c.getDescribe().getName(); + dlrsIsActiveField.field = Schema.dlrs__LookupRollupSummary2__mdt.dlrs__Active__c.toString(); dlrsIsActiveField.value = false; Metadata.CustomMetadata dlrsCustomMetadataRecord = new Metadata.CustomMetadata();