Cloning an order results in OperationCanceledException

Discussions concerning general integration topics.

Moderator: Phil Barton

Post Reply
toddsou
Posts: 75
Joined: Wed Jul 25, 2012 9:39 am

Cloning an order results in OperationCanceledException

Post by toddsou »

Hello,

I am basically trying to clone an order. However, the call to ApplyChanges throws an exception.

In the catch handler, I break on the call to GetMessages() and interrogate the result via the msgs variable. There is only one entry in the Messages list. In the Immediate Window I see the following:
msgs.First()
{SoftPro.OrderTracking.Client.Orders.OrderBase<Order>.OrderModuleErrorMessage}
Item: {Order TS20180323085024}
Property: null
Text: "There are outstanding order module compilation errors."

I am not familiar with this error, nor do I know how to identify or dig into the compilation errors mentioned in the message. Help appreciated. Thanks.

Code: Select all

	   // IOrderStore os passed in to this method...
            //Create an order number, and specify a template to overlay, as well as another order to overlay
            OrderCreationSpec spec = new OrderCreationSpec();
            spec.BaseNumber = DateTime.Now.ToString("TSyyyyMMddHHmmss");
            spec.Templates.Add("201800341AL");

            IOrder order = null;
            try
            {
                order = os.NewOrder(spec);

                // Save the order in the database.
                os.ApplyChanges(order);     // <<-- This line throws the OperationCanceledException 

            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception: ({ex.Message}) ");
                var msgs = order.GetMessages();
                Console.WriteLine($"Num errors: ({msgs.Count()}) ");
            }
            return order;
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Cloning an order results in OperationCanceledException

Post by BobRichards »

You normally see this error when a Python Custom Order Rule (COR) has a syntax error. Check the CORs. If necessary, remove all of them and make sure your code works as expected then add them back - one at a time.
Bob Richards, Senior Software Developer, SoftPro
toddsou
Posts: 75
Joined: Wed Jul 25, 2012 9:39 am

Re: Cloning an order results in OperationCanceledException

Post by toddsou »

Hi Bob-

I did as you recommended. And once I finished putting the last COR back in place, the code worked fine, which I did not expect. Does order of execution come into play here?

That is, if two CORs subscribe to the same event, is there any guarantee wrt order of execution? (e.g., First module listed in the order's CORs editor wins ?)

Thanks.
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Cloning an order results in OperationCanceledException

Post by BobRichards »

As you are alluding to, if multiple CORs target the same context/property, then only one will execute. The order is non-determinate. Don't do it.
Bob Richards, Senior Software Developer, SoftPro
Post Reply