Show answerHide answer
Correct answer: B, F Create a new bundle using gw.transaction.Transaction.runWithNewBundle().Never call commit() within a runWithNewBundle() statement.
Explanation
Answer Option (Which option is correct) B. Create a new bundle using gw.transaction.Transaction.runWithNewBundle().Answer Option (Which option is correct) F. Never call commit() within a runWithNewBundle() statement.
Explanation:
A queried entity must be placed in a writable bundle before it is modified. Add the entity rather than the Query object or an individual property. A managed runWithNewBundle block handles its transaction boundary; a manually created bundle requires an explicit commit after the intended changes.
Why the other options are incorrect:
A. Commit changes individually for each entity:
Committing each entity separately fragments related changes. A failure can leave only part of the intended update saved. Related work should share a deliberate transaction boundary.
C. Explicitly call the commit() method on the bundle outside of a managed block:
A manually managed commit can be valid in some contexts. It is not the managed-block approach selected here. The blanket best-practice claim needs that context.
D. Add all entities to the bundle, not just those which will be edited:
Adding every entity increases the writable bundle unnecessarily. Entities that are merely read need not all be moved. Limit writable state to the transaction work.
E. Obtain a bundle using gw.transaction.Transaction.getCurrent():
getCurrent can be appropriate when a writable current bundle exists. The prompt instead selects an isolated managed transaction. The available context does not justify treating all current bundles as wrong.
References:
Guidewire-authored PolicyCenter 10.1.2 - Bundle transactions

