jamessimone / apex-rollup

Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.
MIT License
212 stars 30 forks source link

Invalid conversion from runtime type String to Decimal #443

Closed garymscott closed 1 year ago

garymscott commented 1 year ago

Hi I've just installed version 1.0.38 (namespaced) and am getting the below error when run from the Recalculation button or via the Recalculated Rollup tab:

17:57:55.0 (220478232)|SOQL_EXECUTE_BEGIN|[51]|Aggregations:0|SELECT owner_count__c,id,admin_count__c,CurrencyIsoCode
FROM Contact
WHERE Id = :objIds
17:57:55.0 (227549898)|SOQL_EXECUTE_END|[51]|Rows:1
17:57:55.0 (233552885)|USER_DEBUG|[74]|INFO|Rollup v1.5.65: starting rollup for:
Type: please.RollupAsyncProcessor.QueueableProcessor
Invocation Point: FROM_SINGULAR_PARENT_RECALC_LWC
Is Full Recalc: true
Is No Op: false
Is Conductor: false
Inner rollups: 0
Rollup Metadata: {
  "attributes" : {
    "type" : "please__Rollup__mdt",
    "url" : "/services/data/v58.0/sobjects/please__Rollup__mdt/m0K3H0000008Y6JUAU"
  },
  "please__LookupFieldOnLookupObject__c" : "Id",
  "please__RollupControl__c" : "m0B3H00000009ffUAA",
  "please__ShouldRunWithoutCustomSettingEnabled__c" : false,
  "please__SplitConcatDelimiterOnCalcItem__c" : false,
  "please__CalcItem__c" : "PlanContactRelation__c",
  "please__CalcItemWhereClause__c" : "Role__c = 'Owner' AND Contact__c = '0033H00000bYrbHQAS'",
  "MasterLabel" : "Owner Count To Contact",
  "please__RollupOperation__c" : "COUNT",
  "please__RollupFieldOnLookupObject__c" : "Owner_Count__c",
  "please__GroupByFields__c" : "Role__c",
  "please__IsRollupStartedFromParent__c" : false,
  "please__IsTableFormatted__c" : false,
  "please__RollupFieldOnCalcItem__c" : "Id",
  "please__IsFullRecordSet__c" : true,
  "please__LookupObject__c" : "Contact",
  "please__LookupFieldOnCalcItem__c" : "Contact__c",
  "Id" : "m0K3H0000008Y6JUAU",
  "DeveloperName" : "Owner_Count_To_Contact",
  "please__RollupToUltimateParent__c" : false,
  "please__SharingMode__c" : "System"
}
Rollup Control: {
  "attributes" : {
    "type" : "please__RollupControl__mdt",
    "url" : "/services/data/v58.0/sobjects/please__RollupControl__mdt/m0B3H00000009ff"
  },
  "please__BatchChunkSize__c" : 200,
  "please__TriggerOrInvocableName__c" : null,
  "please__MaxLookupRowsBeforeBatching__c" : 1000,
  "Label" : "Connect Team Membership Rollups",
  "please__MaxRollupRetries__c" : 10,
  "please__ShouldRunAs__c" : "Synchronous Rollup",
  "MasterLabel" : "Connect Team Membership Rollups",
  "Language" : "en_US",
  "please__ReplaceCalcItemsAsyncWhenOverCount__c" : 1,
  "please__IsDevEdOrTrialOrg__c" : false,
  "please__MaxNumberOfQueries__c" : 50,
  "please__MaxParentRowsUpdatedAtOnce__c" : 200,
  "DeveloperName" : "Connect_Team_Membership_Rollups",
  "please__IsRollupLoggingEnabled__c" : true,
  "NamespacePrefix" : null,
  "please__OnlyRunInFlowContexts__c" : null,
  "please__IsMergeReparentingEnabled__c" : true,
  "please__ShouldDuplicateRulesBeIgnored__c" : false,
  "please__ShouldRunSingleRecordsSynchronously__c" : false,
  "SystemModstamp" : "2023-05-18T16:57:49.000+0000",
  "please__ShouldAbortRun__c" : false,
  "QualifiedApiName" : "Connect_Team_Membership_Rollups",
  "please__MaxQueryRows__c" : 25000,
  "Id" : "m0B3H00000009ff",
  "please__ShouldSkipResettingParentFields__c" : false
}
Calc Items: [ {
  "attributes" : {
    "type" : "PlanContactRelation__c",
    "url" : "/services/data/v58.0/sobjects/PlanContactRelation__c/a0R3H000000jeX3UAI"
  },
  "Id" : "a0R3H000000jeX3UAI",
  "Contact__c" : "0033H00000bYrbHQAS",
  "Role__c" : "Owner",
  "CurrencyIsoCode" : "GBP"
}, {
  "attributes" : {
    "type" : "PlanContactRelation__c",
    "url" : "/services/data/v58.0/sobjects/PlanContactRelation__c/a0R3H000000jeX8UAI"
  },
  "Id" : "a0R3H000000jeX8UAI",
  "Contact__c" : "0033H00000bYrbHQAS",
  "Role__c" : "Admin",
  "CurrencyIsoCode" : "GBP"
}, {
  "attributes" : {
    "type" : "PlanContactRelation__c",
    "url" : "/services/data/v58.0/sobjects/PlanContactRelation__c/a0R3H000000jlUEUAY"
  },
  "Id" : "a0R3H000000jlUEUAY",
  "Contact__c" : "0033H00000bYrbHQAS",
  "Role__c" : "Admin",
  "CurrencyIsoCode" : "GBP"
} ]
Full Recalc Processor: "please.RollupDeferredFullRecalcProcessor"
Is Processed?: true
Class.please.RollupAsyncProcessor.process: line 671, column 1
Class.please.RollupAsyncProcessor.runCalc: line 291, column 1
Class.please.Rollup.batch: line 2366, column 1
Class.please.Rollup.performSerializedBulkFullRecalc: line 577, column 1

17:57:55.0 (242954562)|SOQL_EXECUTE_BEGIN|[62]|Aggregations:0|SELECT Count()
FROM PlanContactRelation__c
WHERE Id != :objIds
AND Contact__c = :recordIds
17:57:55.0 (248394452)|SOQL_EXECUTE_END|[62]|Rows:0
17:57:55.0 (249562654)|USER_DEBUG|[74]|DEBUG|Rollup v1.5.65: Returned amount: 0
SELECT Count()
FROM PlanContactRelation__c
WHERE Id != :objIds
AND Contact__c = :recordIds
Bind keys: {objIds, recordIds}
Access level: SYSTEM_MODE
Class.please.RollupRepository.createQueryLog: line 78, column 1
Class.please.RollupRepository.getCount: line 69, column 1
Class.please.RollupAsyncProcessor.retrieveAdditionalCalcItems: line 576, column 1
Class.please.RollupAsyncProcessor.getUpdatedLookupItemsByRollup: line 1179, column 1
Class.please.RollupAsyncProcessor.process: line 672, column 1
Class.please.RollupAsyncProcessor.runCalc: line 291, column 1
Class.please.Rollup.batch: line 2366, column 1
Class.please.Rollup.performSerializedBulkFullRecalc: line 577, column 1

17:57:55.0 (283904937)|EXCEPTION_THROWN|[518]|System.TypeException: Invalid conversion from runtime type String to Decimal
17:57:55.0 (284000453)|SYSTEM_MODE_EXIT|true
17:57:55.0 (284255566)|FATAL_ERROR|System.TypeException: Invalid conversion from runtime type String to Decimal

Class.please.RollupCalculator.DecimalRollupCalculator.setDefaultValues: line 518, column 1
Class.please.RollupCalculator.GroupByCalculator.performRollup: line 1342, column 1
Class.please.RollupAsyncProcessor.getCalculator: line 1308, column 1
Class.please.RollupAsyncProcessor.getUpdatedLookupItemsByRollup: line 1213, column 1
Class.please.RollupAsyncProcessor.process: line 672, column 1
Class.please.RollupAsyncProcessor.runCalc: line 291, column 1
Class.please.Rollup.batch: line 2366, column 1
Class.please.Rollup.performSerializedBulkFullRecalc: line 577, column 1
17:57:55.0 (284293341)|FATAL_ERROR|System.TypeException: Invalid conversion from runtime type String to Decimal

Here are my CMDTs: image image

Do you have any ideas on what is causing this?

Thanks!

jamessimone commented 1 year ago

This may be an actual bug, but I think for your purposes all you need to do to get this working is remove Role__c from the Group By fields. You aren't trying to do a group by rollup - which basically spits out text grouping by the field in question - and I know that because the where clause you're using for each of these rollups is specific to one role each.

garymscott commented 1 year ago

Hi James thanks for the advice. I’ve tried with and without the role grouping and it didn’t fix it. I’ll try again tomorrow and report back.

On Thu, 18 May 2023 at 18:49, James Simone @.***> wrote:

This may be an actual bug, but I think for your purposes all you need to do to get this working is remove Role__c from the Group By fields. You aren't trying to do a group by rollup - which basically spits out text grouping by the field in question - and I know that because the where clause you're using for each of these rollups is specific to one role each.

— Reply to this email directly, view it on GitHub https://github.com/jamessimone/apex-rollup/issues/443#issuecomment-1553408515, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4CBU7PNJSGVLKAUELJRZTXGZOK5ANCNFSM6AAAAAAYGXBJ7Q . You are receiving this because you authored the thread.Message ID: @.***>

jamessimone commented 1 year ago

@garymscott if you are doing this from a full recalc app page, you need to refresh the page after updating the custom metadata values. The values are cached when the page loads. You should be all set - closing this for now.

garymscott commented 1 year ago

Hi James you were absolutely right I was running into caching issues so didn't consider the grouping to be an issue when actually it was. Thanks again for your help!