Order Version Error on open

Discussions related to custom development with Select.
Post Reply
MattW
Posts: 46
Joined: Tue May 26, 2015 5:17 pm

Order Version Error on open

Post by MattW »

Came across what appears to be a bug with the OrderIdentifier when using the default version retrieved from a search:
The following code throws the error "Exclusive locks are only supported when opening the latest order version.":

Code: Select all

var oi = os.Orders.Where(x => x.Number == owd.OrderNumber).FirstOrDefault();
var identifier = oi.Identifier;
var order = os.OpenOrder(identifier, OrderEditMode.ReadWrite);

However if changed to explicitly use the Latest on OrderIdentifier it works reliably (shown in the following):

Code: Select all

var oi = os.Orders.Where(x => x.Number == owd.OrderNumber).FirstOrDefault();
var identifier = oi.Identifier.Latest;	<-- UPDATE
var order = os.OpenOrder(identifier, OrderEditMode.ReadWrite);

I'd like to confirm that this is indeed a bug, otherwise what is the intended process for reliably opening the latest version of the order (I was of the impression that, unless explicitly specified, OrderInfo.Identifer defaults to the latest version).
BobRichards
Posts: 1377
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Order Version Error on open

Post by BobRichards »

I will forward the activity you have observed for review. Thanks. One way to use the OrderIdentifier to open an order is:

Code: Select all

// Get the order guid from the order store.
//    Constructor will default version to -1 which is used as a flag to mean "most recent".
OrderIdentifier oi = new OrderIdentifier(orderGuid);
IOrder order = os.OpenOrder(oi, OrderEditMode.ReadWrite);
This behavior is discussed in the SDK by searching for "OrderIdentifier". Also, you can see an example of searching and opening orders in the SDK topic "How-To / Standalone Application Development / Open an Order".
Bob Richards, Senior Software Developer, SoftPro
Post Reply