OrderHelper oh = GetService<OrderHelper>();
oh.RegisterOrderSavedHandler(saved_handler);
private void saved_handler(object sender, EventArgs e)
{
IOrder order = sender as IOrder;
// check is order is new or existing
}
and now I am wondering if there is a way to determine if the order is a "new" order, or an existing order.....Is this possible?
There is a SaveCount property exposed by the IOrder interface which starts at 0. You may be able to use that if your definition of new vs. existing is whether or not an order has yet been saved at least once. The value of SaveCount increments each time the order is saved - for any reason - including those triggered forcibly by the application.
That should accomplish what I am looking for, Ill assume that since it starts at 0, the actual value will be 1 when I get access to it as this happens after the order is saved correct?
However, correct me if I am wrong, but auto-saving does NOT fire the Order Saved Event Handler, right?
The save occurs before the event handler is invoked so yes, you would see a value of 1 if it was the first time a particular order was saved. As for your other question, the event handler is always invoked when a save occurs while the order is open in Select, even for auto-save and force-save (e.g. when a document job is kicked off).
No, that's right. When that option is turned on, the order is technically saved before it is opened in Select, so the handler is not invoked (the invocation occurs by way of the editor window itself). If the other option (auto-save every n minutes) is turned on, that will invoke the handler since the order is open in Select. Hope that helps.