执行逻辑beforedelete事件触发器

发布于 2025-01-28 19:22:27 字数 222 浏览 3 评论 0原文

在删除记录之前(例如:councel obj记录),我想更新帐户记录上的字段并将其发送给内容管理,将其保留几秒钟,然后将其删除。

在这种情况下,我使用了beforedelete事件并更新了记录中的字段,并使用更新的记录数据调用了内容管理。该记录已更新新值(我从回收箱中还原后进行了验证),但是在删除记录之前,它没有调用内容管理。是否可以等待几秒钟的任何选择,直到记录在内容管理上更新并删除记录?请分享您的建议。谢谢。

Before deleting the record (Ex: Account obj record), I want to update the field on the account record and send it to content management, hold it for a few seconds, and then delete it.

For this scenario, I used beforedelete event and updated the fields in the record, and called the content management with updated record data. The record is updated with new values (i verified after restoring it from recycle bin), But it is not calling the content management before deleting the record. Is there any option that we can wait for a few seconds until the record is updated on content management and delete the record? Please share your suggestions. Thank you.

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

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

发布评论

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

评论(1

葬花如无物 2025-02-04 19:22:27

您无法直接从触发器上进行呼叫(SF数据库表/行才能锁定并持有人质,直到第三方系统完成,最多2分钟),它必须是异步的。因此,您可能会从@future打电话,但是到那时,主触发器完成,如果您传递了ID,则将删除记录 - 可能是@future返回0行的查询。

忘了关于“握住它几秒钟”的一点。您需要做出一些架构决策。无论如何,删除成功都重要吗?还是您只想在外部系统确认消息后才删除?

  1. 您可以在触发器中查询您的记录(或将整个扳机。它应该只采用原始词,而不是对象/集合,但是您可以始终json.serialize它作为字符串。

  2. 您可以隐藏标准删除按钮并介绍自定义一个。在那里,您将有一个可以发出标注的控制器,等到成功响应返回然后删除?

  3. 您可以重新考虑请求响应的内容。如果您进行标注(或提高平台事件?),那是内容管理系统,然后到达Salesforce和删除(例如,通过REST API)。

  4. 如果您立即删除,希望它们留在回收垃圾箱中,然后外部系统可以查询垃圾箱/使特殊

参见

You can't make a callout straight from a trigger (SF database table/row can't be locked and held hostage until 3rd party system finishes, up to 2 minutes), it has to be asynchronous. So you probably call from @future but by then the main trigger finished, the record is deleted, if you passed an Id - probably the query inside @future returns 0 rows.

Forget the bit about "holding it for few seconds". You need to make some architecture decisions. Is it important that delete succeeds no matter what? or do you want to delete only after the external system acknowledged the message?

  1. You could query your record in the trigger (or take whole trigger.old) and pass to the future method? It's supposed to take only primitives, not objects/collections but you could always JSON.serialize it before passing as string.

  2. You could hide the standard delete button and introduce custom one. There you'd have a controller which can make the callout, wait till success response comes back and then delete?

  3. You could rethink the request-response thing. What if you make the callout (or raise platform event?) and it's the content management system that then reaches to salesforce and deletes (via REST API for example).

  4. What if you just delete right away, hope they stay in recycle bin and then external system can query the bin / make special getDeleted call and pull the data.

See Salesforce - Pull all deleted cases in Salesforce for some more bin-related api calls.

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