Disabling or locking sales order to stop editing
Hi,
I am writing a plugin to stop any edits on a sales order if a delivery docket has been printed.
Originally the client had wanted me just to stop any printing if the delivery docket had already been printed, but now the spec is to stop all editing.
So far, the plugin code works nicely to stop printing. I also have a toolbar button to re-enable printing upon entry of a password.
The disabling/enabling printing code can be removed once I have code to disallow/allow editing.
I am having trouble finding the appropriate code to lock the sales order from editing. I did try SalesOrder.Client.Form.Enabled = False and although this worked it also locked the whole toolbar.
So I took a stab at using the abstract permissions and seeing if I can set it to Disallow. It seems to kinda work but when scrolling through the sales orders using the toolbar arrows, when I land on a sales order which shouldn't be locked it unlocks fine (sometimes - not sure why it doesn't unlock all the time) except for the History Status and Printed/Emailed indicators - these remain uneditable and the font colour is black instead of white.
Can you glance at my code and give me a better idea on the suggested way to prevent editing an order - and also the button I have to Enable Printing should have code to allow editing instead.
See line(s) 55, 56 etc on the attached plugin. And lines 70-76 for the button code.
Thanks
Danny
I am writing a plugin to stop any edits on a sales order if a delivery docket has been printed.
Originally the client had wanted me just to stop any printing if the delivery docket had already been printed, but now the spec is to stop all editing.
So far, the plugin code works nicely to stop printing. I also have a toolbar button to re-enable printing upon entry of a password.
The disabling/enabling printing code can be removed once I have code to disallow/allow editing.
I am having trouble finding the appropriate code to lock the sales order from editing. I did try SalesOrder.Client.Form.Enabled = False and although this worked it also locked the whole toolbar.
So I took a stab at using the abstract permissions and seeing if I can set it to Disallow. It seems to kinda work but when scrolling through the sales orders using the toolbar arrows, when I land on a sales order which shouldn't be locked it unlocks fine (sometimes - not sure why it doesn't unlock all the time) except for the History Status and Printed/Emailed indicators - these remain uneditable and the font colour is black instead of white.
Can you glance at my code and give me a better idea on the suggested way to prevent editing an order - and also the button I have to Enable Printing should have code to allow editing instead.
See line(s) 55, 56 etc on the attached plugin. And lines 70-76 for the button code.
Thanks
Danny