首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如果在父对象上发生任何更新,则更新父对象中的字段的最佳方法

如果在父对象上发生任何更新,则更新父对象中的字段的最佳方法
EN

Stack Overflow用户
提问于 2021-08-06 23:36:58
回答 1查看 1.2K关注 0票数 0

我必须有两个具有主细节关系的对象。如果任何一个对象(父对象或子对象)发生任何更新,我希望更新父对象中的状态选择列表字段。什么是最好的方法?

EN

回答 1

Stack Overflow用户

发布于 2022-04-04 14:41:37

希望这有助于您了解各种可用的解决方案。我已经通过最简单的工作流更新将它们排序给更复杂的流程构建器和最后一个顶级触发器,这与在salesforce上实现解决方案时单击代码的最佳实践产生了共鸣。

您可以在这里使用许多策略,下面我将从简单到复杂(过度杀戮)对它们进行概述:

  1. Workflow:您可以使用两个工作流字段更新来完成此操作:

代码语言:javascript
复制
- one on the parent object when a record is edited, 
  then update the status picklist field on the record .

- and another on the child object when a record is edited,
  then upon selecting `field to update` as option, you will
  be given the parent object and child object as options to
  filter fields on, select parent object to filter fields on
  then select the status picklist field from parent object.

  1. Process Builder:您可以使用流程生成器从子进程更新父记录。

代码语言:javascript
复制
Create a process builder flow on child object and update parent
object along with either of the two:

- create a workflow on the parent object to update the status
  picklist field when a record is edited only.
- or alternatively to the workflow on the parent object, create
  a process builder flow on parent object and update parent object.

  1. Apex Trigger:

代码语言:javascript
复制
Equally you can go to the lengths of writing an apex trigger
upon the parent object `onupdate` trigger and verify if a valid
change was made(meaning the change made to parent was not a
change on the status picklist field), update the the status
picklist field too.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68688372

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档