New Term: Salesforce Transactions

ליאור נכתב על ידי ליאור לביא, עודכן בתאריך 27/10/2023

A transaction, or execution context, is the scope in which our code runs, and at its conclusion, all the DML (Data Manipulation Language) operations defined within it are executed simultaneously against the database. So, if one of them fails, all the others are canceled, and a full rollback is performed.

Transactions are essential means to ensure the completeness of sets of actions against the database, where they depend on each other in such a way that they all must run successfully together or fail together. Partial execution of actions against the database is not allowed.

A common example of such a process is the process of transferring money from one bank account to another. Let's imagine a scenario in which we want to transfer 100 dollars from account A to account B. Clearly, we do not want 100 dollars to be added to account B unless they are first deducted from account A, and we also do not want to deduct 100 dollars from account A without ensuring that they have indeed been added to account B. When both of these actions are carried out within the same transaction, if one of them fails, both will fail, and a full rollback will be executed, ensuring the reliability and completeness of the data.