LoginSignup
0
0

リリース更新:REST API で Apex アクションの例外が発生した場合のロールバックの適用

Last updated at Posted at 2024-05-08

この更新では、例外で終了したトランザクションをロールバックすることで、データの整合性が維持されます。REST API を使用して Apex アクションを実行すると、その例外が発生しても、API によって Salesforce データは変更されません。この更新は、当初は「Connect REST API で呼び出し可能なカスタムアクションの例外が発生した場合のロールバックの適用」という名前で、Spring '23 で最初に使用可能になり、Spring '24 で適用される予定でしたが、適用日が Spring '25 に延期されました。

トリガーの実行準を考えるとREST API の Apex アクション 例外処理で更新前に戻ると思いますね。20ステップの前でエラーになったらこのステップは実行されないんでしょうね。

20 . After the changes are committed to the database, executes post-commit logic. Examples of post-commit logic (in no particular order) include:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm

ただ、このアップデートを素直に読むと今は、この順序に関係ない?ような感じがします。調べてみると今まではトランザクション処理はない(対象外)のようです。よって、上記のトランザクション処理とは別のように思います。

今回のアップデートでレコードから見たら同じトランザクションに入るとのことらしいので、REST APIでは現状では例外があってもロールバックされないと思います。

transaction control with REST API - does it exist?
https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T43bFSAR

How to rollback Status on an object like Lead if the API response was not successfully?
https://salesforce.stackexchange.com/questions/335333/how-to-rollback-status-on-an-object-like-lead-if-the-api-response-was-not-succes

REST の処理はそもそもトランザクションの外、独立した処理なのかもしれませんね。

https://stackoverflow.com/questions/33060968/rest-and-transaction-rollbacks

つづき

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0