Cert++
Close

Transactions for persistent object changes in script code

Key Takeaway

Make changes that must succeed or fail together inside one transaction, such as one Transaction.wrap() callback, so they are committed together or rolled back together.

In B2C Commerce script code, you need a transaction to create, change, or delete a persistent business object. The transaction decides whether a group of related changes is saved as a group or undone as a group, so you plan which changes share a transaction. The dw.system.Transaction class controls transactions, either explicitly with begin() and commit() or implicitly with wrap().

What a transaction does

You can create, change, or delete a persistent business object only inside a transaction. You must start the transaction before you make any of those changes.

The changes in a transaction are saved together when it commits. They become durable only then. A rollback instead reverts every change made so far in the transaction. The business objects it touched return to their previous state.

B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Given a requirement, create and extend the functionality of a JavaScript controller that leverages models, decorators, factories, or helpers following API best practices, and renders a template or returns a JSON response

0/11

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other B2C Commerce Developer studiers.