Skip to content

Assert

Fails the current server workflow script when condition is false.

1
myScript.Assert(condition: any, message?: string):void

Parameters

any condition
    A value evaluated with JavaScript truthiness.

string message optional
    Error text returned in the thrown JavaScript Error.

Remarks

Server workflow scripts only. Use this for guard clauses and invariant checks; it does not display a user message.

Examples

Stop when required data is missing

1
2
var customer = $Xml.Evaluate('Customer/Id');
Script.Assert(customer, 'A customer must be selected before the order is approved.');