Transaction handling in custom job step scripts
Key Takeaway
In a custom job step that updates many persistent business objects such as orders, keep the transactional attribute at its default of false. In the step code, use the dw.system.Transaction API, for example Transaction.wrap(), to change each order in its own transaction instead of running the whole step as one large transaction.
A custom job step script often creates, changes, or deletes persistent business objects, such as orders or products. Those changes become permanent only inside a committed transaction. B2C Commerce gives you two ways to handle transactions in a job step. You can set the transactional attribute in the step type definition so the whole step runs as one transaction. Or you can control transactions yourself in the step code with the dw.system.Transaction API, which is the approach Salesforce recommends.
What a transaction does
You must start a transaction with Transaction.begin() before you create, change, or delete a business object. Your changes become permanent only when Transaction.commit() runs. Transaction.rollback() reverts every change so far, so the objects return to their previous state.