Salesforce自动化工具比较(Workflow, Process Builder, Flow & Apex Trigger)

前言】:由于SF知识一直在不断革新和进化,本文不能保证你看到时的内容是最新的,但能保证的是会定期更新和更正。

4种自动化工具】:

1、Workflow Rules的技术边界Cross-Object Workflow
触发条件:某一个记录被创建/编辑且满足某一标准,该标准指的是选定的对象或与选定的对象相关的某字段等于/不等于/大于...某一个值时触发;
局限:如果对象是lookup关系,仅能更新该选定对象的值,而不能更新与之相关字段的值,简而言之,不能跨对象更新,master-detail可以
缺陷:workflow更新记录消耗CPU,所以当在代码中遇到CPU超限的问题时,可考虑将workflow的更新操作整合进apex code;

2、Process Builder的技术边界:(更新相关字段首选)
触发条件:某一记录被save时;
缺陷:不能删除编辑好的Process,只能Inactive (除非使用Metadata API操作),不能修改已经编辑过的Process,只能clone,触发条件为created/edited;
相比workflow的优势:
a、流程图的方式写逻辑和action更直观;
b、执行action的时候,可以update选定对象的相关字段的值,而不仅局限其对象本身的field;
c、能跨对象更新,不管是跨父级还是跨子级更新都行

注:任何更新字段实际上是通过DML操作实现的,不管操作是绑定在button上还是如何。
最佳实践:实施时请务必遵循一个对象一个Process Builder的原则。以下是Process Builder和NPSP应用程序代码之间相互影响造成的Exception Error,Support给的解决方案:

A solution for this would be to consolidate the six active process builders on the opportunity object and use the best practice of 1 Process per Object. If they can order the OwnerId reassignment that is occurring in the process builder called "Opportunity Owner Reassignment & Target Dept. Update" to come after the Engagement Plan creation, they won't run into this issue.

3. Flow Update New and Changed Records by Using Before-Save Updates in Flows

功能特征:In Spring ’20, creating or updating a record can now trigger an autolaunched flow to make additional updates to that record before it's saved to the database

前置条件:To activate a flow that makes before-save updates, an app builder needs the View All Data permission.

Flow优点:Before-save updates in flows are much faster than other available record-triggered updates.

Flow之于PBA before-save update in a flow is 10 times faster than an update in a record-change process that’s built in Process Builder. Perhaps you’re familiar with Process Builder and using a record-change process to make additional updates to each record that triggers the process. Such a process can set the Region custom field automatically on each new case record. Before-save updates in flows accomplish that same goal, but much more quickly because each record doesn’t get saved to the database again. Avoiding that extra save procedure means skipping another round of assignment rules, auto-response rules, workflow rules, and other customizations that take time to execute.

Flow之于Trigger:A flow that makes before-save updates is similar to a before trigger. In a save procedure, before-save updates in flows are executed immediately prior to Apex before triggers.

Because of their speed, we recommend that you use before-save updates in flows to update fields on new or changed records. You can even avoid the limit for maximum CPU time on the Salesforce servers by replacing Apex code and record-change processes with before-save updates in flows. However, sometimes you need to use a record-change process or an Apex after trigger to:

  • Access field values that are set only after the record is saved, such as the Last Modified Date field or the ID of the new record.
  • Create or update related records.
  • Perform actions other than updating the record that launches the flow.

Action比较】:workflow vs process builder

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值