Order already exists error
Moderator: Phil Barton
Order already exists error
When creating a order by calling OrderTracking.SaveOrder and it failed with an exception, the order was not created. But if trying to create the order again with the same order number, it shows an error of "The order XXX already exists", which means I can not use this order number naymore. How can I remove the locking on the order number so that I can create it again?
Re: Order already exists error
More detail of creating the order: calling OrderTracking.CreateOrder(spec), set values to the IOrder instance obtained, then SaveOrder. So if any error occurs before saving the order successfully, should I delete the order instance by calling OrderTracking.DeleteOrder(IOrder.Id)? What's the recommended way of handling error here? Thanks.
Re: Order already exists error
Once an order number has been consumed, it is thereafter unavailable, even if the particular order is never saved. The order numbering manager is responsible for ensuring that consumed numbers are never used/reused, and that behavior cannot be overridden to "free up" seemingly abandoned numbers, as in your scenario. As far as the DeleteOrder call goes, you won't need to do that if the order was never saved... calling CloseOrder instead will allow the in-memory Order model to be cleaned up properly.