Order already exists error

Discussions related to SoftPro Select Server development.

Moderator: Phil Barton

Post Reply
kqian
Posts: 68
Joined: Wed Feb 23, 2011 4:01 pm

Order already exists error

Post by kqian »

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?
kqian
Posts: 68
Joined: Wed Feb 23, 2011 4:01 pm

Re: Order already exists error

Post by kqian »

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.
Mark McKenna

Re: Order already exists error

Post by Mark McKenna »

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.
Post Reply