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

Record Trigger Flow not executing rollup #468

Closed bchovan73 closed 1 year ago

bchovan73 commented 1 year ago

Hi James, We have a custom object that has a Master/Detail relationship to ServiceAppointment with has a Lookup to Work Order. The flow is executing the rollups as expected. Basically we have fields on the custom object(JHA Onsite Person) that we want SUM'd up on the WorkOrder which is a grandparent object. To the best of my knowledge we have everything set up properly. The record triggered flow runs on Update and has an apex action for performing the CMDT driven rollups and an action for processing the deferred rollups. Attaching some screenshots and a sample apex log.EDIT TO ADD: The rollup works when I use the Rollup Button on the rollup App. flow4 flow3 flow2 flow1 orgdefaultsscreenshot rollupcmdtscreenshot

apex-07L7b00000PhXPVEA3.log

jamessimone commented 1 year ago

@bchovan73 any chance you haven't enabled the Rollup Setting custom setting org default? It's reporting a "no op" no operation, which is typically from the custom setting not having been enabled.

bchovan73 commented 1 year ago

I am pretty sure I did but I will double check when I get back in front of my screen. Thank you.

Sent from my iPhone

On Jul 28, 2023, at 1:52 PM, James Simone @.***> wrote:



@bchovan73https://github.com/bchovan73 any chance you haven't enabled the Rollup Setting custom setting org default? It's reporting a "no op" no operation, which is typically from the custom setting not having been enabled.

— Reply to this email directly, view it on GitHubhttps://github.com/jamessimone/apex-rollup/issues/468#issuecomment-1656182724, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APDPY5PWRYZO5XGHYDN2D63XSQDABANCNFSM6AAAAAA23UTAGY. You are receiving this because you were mentioned.Message ID: @.***>

bchovan73 commented 1 year ago

@jamessimone I have double checked and the custom setting was indeed enabled. customsetting1

jamessimone commented 1 year ago

Oh! @bchovan73 are you using the right Rollup action? You want the CMDT action? I want to make sure you're not using the base action (where you have to supply ALL the data). If you are using the base action, that might explain the "no-op!" message in the logs.

bchovan73 commented 1 year ago

Yes I am using the CMDT action. I will double check of course.

jamessimone commented 1 year ago

You are using the CMDT action, apologies for asking that as I can see you're using the right action in the log - is Work_Order__c a custom field on your Service Appointment object to get around limitations with ParentId ? There's nothing obviously wrong with your setup, but something about it is causing the rollup(s) in question to be removed prior to actually being stored for processing.

I've never seen something like this - ideally, I'd love to know what's going on in the Rollup.processCustomMetadata method, as that's the most likely place where wires could be getting crossed. I guess, as well, that a good place to start would be validating that the code gets into that method. I don't know how comfortable you are with Apex debugging, but I'm happy to assist in any which way. One other thing to check is the message returned with Flow - right after the log message that shows up in what you attached, it's also possible for the output for the Flow to have No records to rollup, returning early show up. I'm confident that we can figure out what's happening here and get this working for you.

chazwatkins commented 1 year ago

Hey James,

We're also not sure why we have the Work_Order__c field. It's an artifact from a consultancy that set up Field Service a few years ago. I did find that the Field Service Starter Kit by SalesforceLabs also creates Work_Order__c. Supposedly, non-polymorphic fields are more friendly to formulas and "other platform customizations" per the demo video.

Your suspicion about using Work_Order__c vs. ParentId was spot on. We switched it to ParentId, and the RecordTriggeredFlow works.

Thanks for the quick responses and willingness to help.

bchovan73 commented 1 year ago

That field was definitely created to get around the polymorphic lookup limitations.

On Aug 3, 2023, at 9:59 AM, Chaz Watkins @.***> wrote:

Hey James,

We're also not sure why we have the Work_Order__c field. It's an artifact from a consultancy that set up Field Service a few years ago. I did find that the Field Service Starter Kit by SalesforceLabs https://appexchange.salesforce.com/appxListingDetail?listingId=a0N4V00000FguIKUAZ also creates Work_Order__c https://youtu.be/AbqlAmYgJfQ?t=79 too. Supposedly, non-polymorphic fields are more friendly to formulas and "other platform customizations".

Your suspicion about using Work_Order__c vs. ParentId was spot on. We switched it to ParentId, and the RecordTriggeredFlow works.

Thanks for the quick responses and willingness to help.

— Reply to this email directly, view it on GitHub https://github.com/jamessimone/apex-rollup/issues/468#issuecomment-1664148729, or unsubscribe https://github.com/notifications/unsubscribe-auth/APDPY5OIR5ZJHVW2GV623A3XTO4EDANCNFSM6AAAAAA23UTAGY. You are receiving this because you were mentioned.

jamessimone commented 1 year ago

No problem, happy to assist!