SFDO-Community / declarative-lookup-rollup-summaries

Declarative Lookup Rollup Summaries (DLRS) is a community built and maintained Salesforce application that allows you to create cross object roll-ups declaratively - no code! For install instructions and documentation, visit our website https://sfdo-community-sprints.github.io/DLRS-Documentation/
https://sfdo-community-sprints.github.io/DLRS-Documentation/
BSD 3-Clause "New" or "Revised" License
690 stars 237 forks source link

RollupService fails on Nonprofit Cloud's standard 'Program' object #1396

Closed groundwired closed 10 months ago

groundwired commented 11 months ago

Describe the bug When rolling up from a custom child object to the Nonprofit Cloud's standard 'Program' object, either via the child trigger or using the scheduled rollup job, the following Apex error occurs:

dlrs.RollupService.triggerHandler(Schema.SObjectType) FATAL_ERROR|System.QueryException: sObject type 'Program' is not supported.

To Reproduce Steps to reproduce the behavior:

  1. Create an org with the new Nonprofit Cloud and install DLRS. There will be a new standard object called 'Program'.
  2. Create a custom child object with a lookup to the standard 'Program' object.
  3. In DLRS, create a simple rollup that counts child records and saves to a number field on the parent. Make it a 'Realtime' rollup, install the child trigger, and activate.
  4. Add a new Program record, and then add a child record.
  5. See the following error message:

    System.QueryException: sObject type 'Program' is not supported.

Expected behavior This rollup works when running "Full Calculate" - it should also work with Realtime triggered calculations or scheduled rollups.

Screenshot 2023-10-16 at 1 21 21 PM

Additional context The rollup works perfectly when we click Full Calculate - in other words, there's no problem with the aggregate query that is used by the rollup. The error occurs in a subsequent step - I assume it is when the DLRS code in RollupService tried to query or update the Program object.

Here is the actual query that it runs to do the rollup: SELECT Target_Programc, Count(Id) lre0 FROM Referralc WHERE Target_Programc in ('11WDp000000L04lMAC') AND (Referral_Date__c = LAST_N_DAYS:365) GROUP BY Target_Programc

DLRS is running in v58.0 - I tried running my trigger in both 58.0 and 59.0 with the same result. I also tried running with User and System sharing mode with the same result.

Note that I also tried changing Calculation Mode to Scheduled. When the rollup service ran on schedule, it hit the same error as the triggered rollup. However, the Full Calculate still works fine.

I have no way of figuring out where the error occurs in the package, but in general I suspect two possible issues with the Nonprofit Cloud 'Program' object. 1) Since this is a new object, it is possible that some Apex functionality isn't working properly in v58.0 (or maybe not working properly at all). 2) My user has all the appropriate licenses and permsets to access the Program object, but it is possible that the Apex code is unable to use those objects or fields for some reason related to security or licensing.

groundwired commented 11 months ago

I created an unmanaged org and reproduced the bug there. The reason this fails is that the RollupDmlGuard and RollupDmlGuardTest classes are still at v56.0. Until this is fixed, no objects released in v57.0 or later will be compatible.

groundwired commented 11 months ago

I tested this update - it fixes the bug!

aheber commented 11 months ago

Fantastic find!

Rather than only updating the API versions, I'd like a chance to fix whatever it is in RollupDmlGuard that is making it API dependent. We've been slowly trying to make DLRS support objects that are ahead of it's API version so we don't have problems like this. I'd like to close this gap as well.

Can you provide reproduction steps or if you're so inclined, take a look at the class and give us a starting point for which parts seem to be causing the problem?

github-actions[bot] commented 10 months ago

Included in beta release 2.20 (Beta 1)

github-actions[bot] commented 7 months ago

Included in production release 2.20