Page 1 of 1

Sales Order line adding, when does it fire in v 7.2?

PostPosted: Tue Aug 28, 2018 2:53 pm
by DannyC
Typically I use the SalesOrder.SalesOrderLineAdding or SalesOrder.SalesOrderLines.Adding when I need to write some code to intercept for whatever reason adding an item to a sales order. e.g. maybe that staff isn't allowed to add that item, or it doesn't comply with some other rule.

This has worked fine up to 7.0.175.

I'm doing some plugins in 7.2 and I am finding that both those events fire when a sales order is loaded also, not just when a line is added.

The only event which seems to fire as a sales order line is added is SalesOrder.SalesOrderLines.AddInventoryItemStart. The problem with AddInventoryItemsStart is that it has the following arguments
Code: Select all
string inventorySeed, JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLineCollection.SalesOrderLineInventorySeedTypes KitSeedType, ref object NewKey ,JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine KitHeader, int LineNumber)

but the SalesOrderLine object KitHeader is null.

So I guess the issue is twofold
i) The line adding events fire even if you're just loading a sales order, it shouldbe when a new item is added
ii) The KitHeader object passed into AddInventoryItemsStart is null. Shouldn't it be the line object?

Cheers

Re: Sales Order line adding, when does it fire in v 7.2?  Topic is solved

PostPosted: Tue Aug 28, 2018 3:09 pm
by Scott.Pearce
You can still use SalesOrder.SalesOrderLineAdding or SalesOrder.SalesOrderLines.Adding, just take a look at the Item.SalesOrderLines.Reading property in your code to determine whether to execute or not.

Re: Sales Order line adding, when does it fire in v 7.2?

PostPosted: Tue Aug 28, 2018 3:12 pm
by Scott.Pearce
Further, in AddInventoryItemStart, the KitHeader object will only be set to a sales order line object when the line being added is a kit component - the KitHeader indicates what it's kit header line is (if any).

Re: Sales Order line adding, when does it fire in v 7.2?

PostPosted: Tue Aug 28, 2018 4:51 pm
by DannyC
the KitHeader object will only be set to a sales order line object when the line being added is a kit component


Ahhhh, I get it.
I've been able to use the Reading property, so all good.