Automations Running with Unresolved Errors

Questions about and code samples for automation process code snippets within Select.
Post Reply
elimalone19
Posts: 23
Joined: Mon Jan 31, 2022 2:26 pm

Automations Running with Unresolved Errors

Post by elimalone19 »

I have created a few automations with custom code snippets and frequently they will fail with the following error:

Code: Select all

Error: The order has unresolved errors. Any outstanding errors must be resolved before the order can be saved.
Sometimes these automations work correctly, but sometimes they fail because of other errors in the file. What is the best practice for dealing with this? I don't want to have to go in and keep re-running failed automations (they seem to always work the second time). Is there a way to tell an automation not to trigger if there are other unresolved issues in the file?
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Automations Running with Unresolved Errors

Post by BobRichards »

This message occurs if the order state has been changed and the order is in an invalid state. A more descriptive message would be displayed if you opened the order in the Select UI and did the same operations. The automation snippet must perform the same additional steps that a human would do to resolve the errors.

If they always run the second time then something must have changed - either in the order or in the snippet. If a snippet fails, I would recommend opening the order in Select and performing the same steps - in the same order - as done in the snippet. It should fail in the same way. You must edit your snippet to take additional steps to take care of the errors.

You should not have to manually re-run snippets. This is a sign that the initial condition of the order does not match the expectation and the code is is not adequate or something unexpected is occurring and the order should be reevaluated.

FYI: You can tell if there are any errors by looking at the list of errors and warnings for the order. If you search the list of contains any IOrderMessage items with a Level of OrderMessageLevel.Error, then the order will not be saved. See this topic for an example of getting the messages.
Bob Richards, Senior Software Developer, SoftPro
Post Reply