Get Errors and Warnings Panel messages in standalone applications

Discussions related to custom development with Select.
Post Reply
BobRichards
Posts: 962
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Get Errors and Warnings Panel messages in standalone applications

Post by BobRichards » Mon May 25, 2020 2:17 pm

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();
}
Bob Richards, Software Developer, SoftPro

Post Reply