Salesforce Flow:哪个表现更好?在获取元素或默认值中分配变量?

发布于 2025-02-11 21:46:58 字数 228 浏览 2 评论 0原文

由于APEX超时,我们公司最近一直在重构流动,我们正在尝试确定哪种方法更有效地运行。

以前,我们将获得一个获取元素,以将父记录的值分配给变量。但是,看来我们还可以自行创建变量,然后将父记录字段的值定义为默认值。

前任。 {!$ record.parent_record__r.value}

我的问题是,在后端,如果我使用上面的示例设置值,是否对每个变量执行DML?哪种方法更有效,哪种方法是最佳实践?

Our company has been refactoring flows lately due to Apex timeouts, and we're trying to decide which method runs more efficiently.

Previously, we would get a Get element to assign values of a parent record to variables; however, it appears we can also create variables on their own and then define the value of a parent record's fields as the Default Value.

Ex. {!$Record.Parent_Record__r.Value}

My question is, on the backend, is it performing a DML for each of those variables if I set the value using the example above? Which method is more efficient, and which is best practice?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红尘作伴 2025-02-18 21:46:59

我的问题是,在后端,如果我使用上面的示例设置值,它是否为每个变量执行DML?

我的问题是,在后端,如果我使用上面的示例设置值? 为我的测试设置该值, 设置。我不知道它是否与您的情况相匹配,但认为它会起作用。

project__c

--- project_item__c(通过主数据连接的子对象)

两个对象都有虚拟__c(文本:255)字段。我写了用用例来复制upsert上父母的现场值。

我认为写了两个记录触发流。在上下文(快速字段更新)

方案1:

  • 执行获取

方案2:

  • 使用关系字段

我打开了开发人员控制台。将我的调试级别设置为最好的。我对子对象进行了更新调用,每种情况都停用了另一个流程。

调查结果:

方案1:

  • 1 DML
  • 62 CPU时间

”

://i.sstatic.net/kall4.png“ alt =“在此处输入图像说明”>

scanerio 2:

  • 0 dml
  • 3 cpu time

​/I.SSTATIC.NET/5zhde.png“ rel =” nofollow noreferrer“>

哪种方法更有效,哪种方法是最佳实践?

在这里对个人品味有点主观。我更喜欢流量最少的节点,但仍然很容易阅读。在这种情况下,如果效率更多是最佳实践,那么一定要通过查找路线进行分配。无论如何,我通常都不考虑它。通常也更容易。

My question is, on the backend, is it performing a DML for each of those variables if I set the value using the example above?

For my test, I did the following setup. I don't know if it matches your situation but thought it would work.

Project__c

--- Project_Item__c (Child object connected via master-detail)

Both objects have Dummy__c (Text: 255) field. I wrote my use-case to copy down the field value from the parent on upsert.

I think wrote two record trigger flows. BEFORE context (Fast Field Updates)

Scenario 1:

  • Perform Get

Scenario 2:

  • Use relationship field

I opened up the developer console. Set my debug level to Finest. I performed an update call on the child object with each scenario while the other flow was deactivated.

Findings:

Scenario 1:

  • 1 DML
  • 62 CPU time

enter image description here

enter image description here

Scanerio 2:

  • 0 DML
  • 3 CPU time

enter image description here

enter image description here

enter image description here

Which method is more efficient, and which is best practice?

That is a little subjective here to personal taste. I prefer my flows to have the fewest nodes possible but still be easy to read. In this case, if efficiency is more the best practice, definitely go the assignment via lookup route. I generally do it that way anyways without thinking about it. Its usually easier too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文