Page 1 of 1

Sales Orders. Event after all kit components have been added

PostPosted: Fri Sep 14, 2018 12:19 pm
by DannyC
Hi,
I'm looking for an event which fires after all kit components have been added.
I thought I could use
Code: Select all
salesOrderForm.SalesOrder.SalesOrderLines.KitAdded
but it doesn't fire. Not sure if it's a bug - I am using 7.2.

Anyway, I thought I could use instead
Code: Select all
salesOrderForm.SalesOrder.SalesOrderLineAdded
but it fires when the kit header has been added, before all the kit components have been added.

I need to interrogate all the kit components (via the LineAdded event and checking for SalesOrderKitLineTypes.e_SalesOrderKitComponent), then do some stuff if any kit components meet a condition once all components have been added.

I'm struggling to find the best way to do this. Any assistance would be appreciated.

cheers

Re: Sales Orders. Event after all kit components have been a

PostPosted: Fri Sep 14, 2018 12:30 pm
by Mike.Sheen
Hi Danny,

The SalesOrderLines has a special event "AddInventoryItemEnd" which is raised at the very end of adding an inventory item to a sales order - including after all components are added.

Mike

Re: Sales Orders. Event after all kit components have been a

PostPosted: Fri Sep 14, 2018 12:31 pm
by Scott.Pearce
Try using
Code: Select all
salesOrderForm.SalesOrder.SalesOrderLines.AddInventoryItemEnd


EDIT: Beaten by Mike!

Re: Sales Orders. Event after all kit components have been a

PostPosted: Fri Sep 14, 2018 12:42 pm
by DannyC
lol. Nice to have double confirmation!

Testing now.......


EDIT: That isn't firing either. Bug? Other suggestion?
EDIT 2: Ok, getting wierder. I created a brand new plugin without any other code. And all I have is a MessageBox to prove that it is firing. And guess what? Both SalesOrderLines.KitAdded and also SalesOrderLines.AddInventoryItemEnd are both working OK! Go figure. I have no idea why they're not firing in my plugin which has other code on other events.

Is there any way that those events can be prevented from firing?

EDIT 3: So this is getting stranger. I remmed out ALL my code & am just left with a simple MessageBox on the KitAdded event. Exactly as per new plugin but with different naming for the code blocks. And it still doesn't fire. I also have some custom fields in my plugin, on Inventory Maintenance.

Re: Sales Orders. Event after all kit components have been a

PostPosted: Fri Sep 14, 2018 1:09 pm
by Scott.Pearce
Fires for me on 7.2. I've attached a test plugin.

Re: Sales Orders. Event after all kit components have been a

PostPosted: Fri Sep 14, 2018 1:11 pm
by Scott.Pearce
If the add is cancelled, i.e. something is listening to the Adding event and setting it's e.Cancel property to true.

You should disable all other plugins, then start stripping back your code to isolate.

Re: Sales Orders. Event after all kit components have been a

PostPosted: Fri Sep 14, 2018 1:36 pm
by DannyC
I think I have a workaround.
It seems 99% certain that my original plugin had some odd corruption, coz I just created a new plugin, copied all my code over & now it IS firing on KitAdded!

Re: Sales Orders. Event after all kit components have been a  Topic is solved

PostPosted: Fri Sep 14, 2018 1:42 pm
by Mike.Sheen
DannyC wrote:I think I have a workaround.
It seems 99% certain that my original plugin had some odd corruption, coz I just created a new plugin, copied all my code over & now it IS firing on KitAdded!


If weird stuff like that happens, just exit Jiwa, and then delete the \ProgramData\Jiwa Financials\Jiwa 7 folder - that'll remove any previously built assemblies and force a recompile when you login.

You shouldn't have to do that, as we do update the *.dll.RowHash file in the \ProgramData\Jiwa Financials\Jiwa 7\...\Runtime folders whenever a plugin is edited, which will cause the plugin to be recompiled on login - but there is the odd occasion where I've seen the assembly in the Runtime folder of the plugin somehow stale - so a previous version of the plugin is actually run.