0

Given that we do not have in-house development resources and my Apex abilities are pretty basic, I usually try to stick to Process Builder, Flow, various out-of-the box declarative assignment/validation/etc rules.

But with self-updating automations (that is, a change on a record triggering an update on that same record), it occurs to me that the more efficient option would be a before trigger instead. It's less maintainable but it also takes less DML.

Generally speaking - is it best practice to have all self-updating automations be triggers then (as opposed to after update Processes that might even need to be recursive)?

Edit: To actually ask a specific question - I have a requirement to perform an update on every record on an object on every edit. I'm concerned about DML efficiency for this need in particular, but then the broader question occurred to me as well.

  • 1
    Have you looked into @InvocableMethod annotated methods in apex? You can call those from a Process. – Jesse Milburn Oct 18 '17 at 13:47
  • 1
    A little bit opinion based there, and it also very much depends on the scale of your org. In a large implementation, efficiency is key. In some others, maintainability may trump that concern. – Adrian Larson Oct 18 '17 at 13:55
  • @glls Sorta, but I suppose it's those types of discussions that prompted my desire for community input. I do favor declarative automation for most things, but now that I'm more familiar with the dev side of things, I'm realizing the limitations and inefficiencies more and more. I am a solo admin but I want to build a scalable foundation rather than a gunked up declarative org with way too many DMLs happening when they don't need to. – Mike Oct 18 '17 at 14:04
  • @AdrianLarson Added a specific question to the end (my actual need at the moment). – Mike Oct 18 '17 at 14:04
5

If what you care about is efficiency, then there is no ambiguity here. Trigger is more efficient. It will take less CPU time and, as you noted, not add any needless database operations.

Normally my advice is clicks-not-code, but with Process Builder, sometimes the costs outweigh the benefits. My advice to you is to make sure you study up on:

  • Thanks! Needed someone to tell me it was unambiguous. Hoping for the day when PB can trigger before record save... – Mike Oct 18 '17 at 16:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.