Locking Cartage Grid on Sales Order.  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Locking Cartage Grid on Sales Order.

Postby Ernst » Tue Aug 08, 2023 12:32 pm

On JIWA721.

We dont want users to use Cartage 2 and 3 Only the top cartage line in Sales Orders.Have put this piece of code into LoadForm, ReadSalesOrder, Copy Sales Order, and CreateEnd

Works great for LoadForm, ReadSalesOrder, Copy Sales Order, but refuses to work for CreateEnd, which is probably the most important one, when they are making a new order and entering freight.
Is there something special to do to get it to work in New Sales Orders?

Code: Select all
      Dim salesOrderForm As JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm = DirectCast(salesOrder.Client, JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)
      salesOrderForm.grdCartage.LockRow(1,True) 
      salesOrderForm.grdCartage.LockRow(2,True)
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: Locking Cartage Grid on Sales Order.  Topic is solved

Postby SBarnes » Tue Aug 08, 2023 5:28 pm

Without seeing the entire code it's hard to comment but that's not going to help you anyhow as every time a line on the sales order changes display line gets called which in turn calls Display cartage which goes and sets locked cells etc. on the grid.

You might be better going after the property change event on the sales order and just resetting the value to zero, if its been set to a value.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Locking Cartage Grid on Sales Order.

Postby Mike.Sheen » Tue Aug 08, 2023 6:09 pm

As Stuart mentioned, a display of any line will cause the cartage grid to be redisplayed (and locked / unlocked) via the DisplayCartage method - so you'll need to add handlers for everywhere that results in the DisplayCartage method being called directly or indirectly.

These are the properties that I've identified you'll need to handle and lock your cartage grid rows in:
  • SalesOrder.SalesOrderLineAdded
  • SalesOrder.SalesOrderLineChanged
  • SalesOrder.SalesOrderLineRemoved
  • SalesOrder.Created
  • SalesOrder.Read
  • SalesOrder.Copied
  • SalesOrder.Deserialized
  • SalesOrder.PropertyChanged

Note that there might be some overlap in the events - such as when you add a line to a sales order you'll get both the SalesOrder.SalesOrderLineAdded event and the SalesOrder.PropertyChanged event - so you probably don't need to be handling both, but it'll ensure consistency in behaviour if you do.

Note also that the permissions system will also come in after any handling of events and displaying by the form and lock things based on permissions - your plugin will likely be adding handlers in the Setup rather than the SetupBefore plugin class, so if you choose to unlock anything you may be circumventing any permissions applied - you probably only are locking, but I just thought I'd mention that in case you were doing some unlocking of grid cells.
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Locking Cartage Grid on Sales Order.

Postby Ernst » Wed Aug 09, 2023 11:55 am

Thanks Mike and Stuart. It looks like the code is going to be overloaded switching the grid off everytime, and I still may not catch all the cases.
Ive tried stuart suggestion and just made it zero if they try and put something in there. Should be good for now.

Code: Select all
SalesOrderHistorys_Changed

      If (e.PropertyName = "CartageCharge2" And SalesOrderH.CartageCharge2.ExGSTAmount <> 0) Or (e.PropertyName = "CartageCharge3" And SalesOrderH.CartageCharge3.ExGSTAmount <> 0 ) Then
         Msgbox ("Freight Charge Lines 2 and 3 should not be used at Lube, please use top Courier line ")
         SalesOrderH.CartageCharge2.ExGSTAmount = 0
         SalesOrderH.CartageCharge3.ExGSTAmount = 0         
      End If
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: Locking Cartage Grid on Sales Order.

Postby Mike.Sheen » Wed Aug 09, 2023 3:43 pm

Ernst wrote:It looks like the code is going to be overloaded switching the grid off everytime


Nonsense. If you try it, you'll see that the inefficiency of locking rows repeatedly is not noticeable - microseconds per invocation.
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Locking Cartage Grid on Sales Order.

Postby SBarnes » Wed Aug 09, 2023 5:46 pm

I am not sure how you are going to miss something given Mike gave you the list but the attached should do what you need.
Attachments
Plugin Lock Cartage Grid.xml
(35.88 KiB) Downloaded 78 times
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Locking Cartage Grid on Sales Order.

Postby Ernst » Fri Aug 18, 2023 9:50 am

OK thanks, will give that a go..Thanks for help
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: Locking Cartage Grid on Sales Order.

Postby Ernst » Fri Aug 18, 2023 9:57 am

That plugin works perfectly Stuart Thx
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: Locking Cartage Grid on Sales Order.

Postby SBarnes » Fri Aug 18, 2023 5:46 pm

You are welcome, but Mike did the initial heavy lifting by providing the list of events.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: Google [Bot] and 32 guests