Prevent Sales Order line changing  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Prevent Sales Order line changing

Postby indikad » Thu Apr 07, 2016 5:26 pm

I am looking for a sales "order line changing" event and cannot find one...

seems that it may not be there according to this post below ?

viewtopic.php?f=26&t=383&p=1267&hilit=Line+changed#p1267

I need to stop a user from editing lines such as quantity and price without having to write code to remember previous values etc .. etc..
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Prevent Sales Order line changing

Postby Mike.Sheen » Thu Apr 07, 2016 10:00 pm

indikad wrote:I am looking for a sales "order line changing" event and cannot find one...

seems that it may not be there according to this post below ?

viewtopic.php?f=26&t=383&p=1267&hilit=Line+changed#p1267

I need to stop a user from editing lines such as quantity and price without having to write code to remember previous values etc .. etc..


There are some options open to you relating to this.

If you create a plugin which adds a handler for the grid change event in the "SetupBeforeHandlers" of the FormPlugin, you can then decide in code to cancel the edit by throwing a ClientCancelledException - this will cause a silent fail (no message to the user). If you want to display a message, you can just throw a new exception (of any type, just not our ClientCancelledException).

That will stop the change being pushed to the business logic and it will be as though the edit never occurred as far as the business logic is concerned. However, the user will be left looking at the values in the grid thinking their changes have been accepted. You can push back into the grid the values from the business logic at this point so they see their edit "undone", but keep in mind this may fire another change event - so you may need to introduce some logic to know who's changing the grid - the user, or your code - otherwise you'll blow the stack.

There are also other events the grid provides which may assist - when a user edits a cell there is an event which affects the EditMode of the cell - you could hook into that to work out if the edit mode has changed, and then perform your validation and set the cell contents back to what it was (from memory with some editmode change events you get the before and after values).

You can also set the MinValue and MaxValue for the cell, if that's suitable (i.e.: a numeric or date type) - you'd do that in the LineDisplayed event of the form - this will prevent the user from entering a value outside the range specified, and would make everything a lot simpler.

If you get stuck on this, post back here and I'll whip up a sample to do what you want.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Prevent Sales Order line changing

Postby indikad » Fri Apr 08, 2016 5:10 pm

Hi Mike,

Thanks for these tips - I will keep these saved for future work as well..

Unfortunately I could not see a way to avert myself of the anomalies of a lot of coding to get the job done as I needed - so resorted to simply not letting user save if an edit was made on the grid. Not very friendly but achieves my objective but with a bit of grief to the user ( he will lose all other edits too ).

when you get a chance I would like to see your expert coding - please.

Thanks.
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Prevent Sales Order line changing  Topic is solved

Postby Mike.Sheen » Thu Apr 14, 2016 2:50 pm

indikad wrote:Unfortunately I could not see a way to avert myself of the anomalies of a lot of coding to get the job done as I needed - so resorted to simply not letting user save if an edit was made on the grid. Not very friendly but achieves my objective but with a bit of grief to the user ( he will lose all other edits too ).

when you get a chance I would like to see your expert coding - please.

Thanks.


Attached is a sample when demonstrates the cancelling of an edit conditionally on sales orders for the "Price Ex." column.

Mike
Attachments
Plugin Sales Order - Conditional Edits.xml
Sample plugin
(31.69 KiB) Downloaded 502 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests