Page 1 of 1

Writing a file different if form docked/undocked

PostPosted: Tue Oct 14, 2014 4:35 pm
by DannyC
Hi,

I've written a plugin which writes a file to disk when a sales order is processed.
The code works fine when the form is undocked, but if it is docked it displays an error.

Can you assist to fix up the code so it works if the sales order form is both docked and undocked?

Thanks

Danny

Re: Writing a file different if form docked/undocked  Topic is solved

PostPosted: Wed Oct 15, 2014 9:41 am
by Mike.Sheen
Hi Danny,

Attached is a modified version of your plugin which works.
Plugin Export XML on SO Process.xml
Revised plugin
(33.06 KiB) Downloaded 415 times


The problem was your use of the shared ActiveForm property. When a form is docked the ActiveForm is the MDI parent form. When undocked, it would always be the sales order form with the focus. You seem to have used ActiveForm simply to get access to the sales order business logic. The Processed event you were hooking into does receive a sender argument - which is the sales order business logic. So in this case you don't need the form - you actually need the business logic. The modifications I made to your plugin do exactly that.

Mike

Re: Writing a file different if form docked/undocked

PostPosted: Thu Oct 16, 2014 11:44 am
by DannyC
As a non-programmer, I think I get it!
Thanks Mike - great help as always.

Cheers

Danny