Skip to content

Isolated

Runs a callback in a new, independent database transaction.

myScript.Isolated(fn: () => T):T

Parameters

() => T fn
    The synchronous callback to execute.

Returns

The value returned by fn.

Remarks

Server workflow scripts only. The new transaction uses read-committed isolation and commits when the callback completes successfully. It is independent of the ambient transaction: a later rollback of the outer transaction does not undo this work. If this callback throws, its own transaction is rolled back; the error then propagates to the caller.

Example

1
2
3
4
5
6
var auditReference = Script.Isolated(function () {
    // Database work performed here commits when this callback succeeds.
    return NewId();
});

// A later outer-transaction rollback does not undo successful isolated work.