Page 1 of 1

Get Errors and Warnings Panel messages in standalone applications

Posted: Mon May 25, 2020 2:17 pm
by BobRichards
In a standalone API app when you are debugging your program, an order save will fail if you did not set all the properties required by the order rules. To see what failed, you can easily retrieve the messages that are normally displayed on the Select UI Errors and Warnings panel. After saving the order, the messages are set with any Errors, Warnings, or Information statements generated by the order rules.

This is also a good way to create order model integration tests since you can see all messages.

Code: Select all

IOrder order = ...
try
{
    ...
    
    // Save the order.
    os.ApplyChanges(order);
}
catch (OperationCanceledException ex)
{
    // Save errors occurred.
    var msgs = order.GetMessages();
}