I was wondering if you have a rollup helper tool which is active, and the same rollup summary in an apex trigger which is active, which one would take precedence. If they are both rolling up on the same field but do slightly different things, which rollup would actually be performing the shown rollup?
-
1By 'rollup helper tool', are you talking about the Declarative Lookup Rollup Summary Tool?– Derek FCommented Mar 26, 2017 at 23:20
-
@DerekF So by Rollup helper tool, I am referring to the salesforce rollup application. So this as opposed to the apex using the DLRS in a separate trigger.– dgelinas21Commented Mar 26, 2017 at 23:48
-
Additionally, are there any tradeoffs to using the DLRS as opposed to using apex triggers without DLRS performance wise, or any other potentially large tradeoffs– dgelinas21Commented Mar 26, 2017 at 23:49
-
If by Salesforce rollup application then the apex version cannot modify the rollup field anyway as it is read only. Still confused on your pieces– EricCommented Mar 27, 2017 at 4:37
1 Answer
Rollup helper tool generates a Trigger, and I assume you also have your logic in a separate trigger.
Quoting from documentation:
The order of execution isn’t guaranteed when having multiple triggers for the same object due to the same event.
For example, if you have two before insert triggers for Case, and a new Case record is inserted that fires the two triggers, the order in which these triggers fire isn’t guaranteed.
Hence, as per best practice its recommended to have single trigger on an Object.
Psuedo code for trigger and class:
// trigger
trigger on Account AccountTrigger(event..) {
// DLRS logic
AccountTriggerHandler.performRollupFromDLRS();
// your custom logic
AccountTriggerHandler.performYourLogic();
}
// class
public class AccountTriggerHandler {
public static void performRollupFromDLRS() {
// code from DLRS
}
public static void performYourLogic() {
// your logic start here
}
}