CarrierChange Breakout doesnt sent sales order object  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

CarrierChange Breakout doesnt sent sales order object

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

See image when doing a change to Carrier, I'd like to do some logic. But the salesorderhistory.CarrierChanged
breakout supplies HistoryNo, and FieldName, which means I cannot access the rest of the sales order object to check things. Do I have to do some fancy workaround, or is there a way to access the salesorder object, even though its not passed in parameters.

Untitled.jpg
Untitled.jpg (33.63 KiB) Viewed 2107 times
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: CarrierChange Breakout doesnt sent sales order object  Topic is solved

Postby Mike.Sheen » Fri Aug 18, 2023 10:57 am

Use a lambda function as the event handler to access whatever is in scope.

Code: Select all
Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
   If TypeOf JiwaForm Is JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm Then
      Dim salesOrderForm As JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(JiwaForm, JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
      
      AddHandler salesOrderForm.SalesOrder.SalesOrderHistorys.CarrierChanged,
         Function(ByVal HistoryNo As Short, ByVal FieldName As String)             
            SalesOrderHistorys_CarrierChanged(HistoryNo, FieldName, salesOrderForm.SalesOrder)
         End Function
   End If
End Sub

Private Sub SalesOrderHistorys_CarrierChanged(ByVal HistoryNo As Short, ByVal FieldName As String, SalesOrder As JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)
   ' Now in here you have access to the sales order
End Sub
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: CarrierChange Breakout doesnt sent sales order object

Postby Ernst » Mon Aug 21, 2023 2:08 pm

Very Clever, Never knew you could do that.. Thanks Mike.
User avatar
Ernst
Kohai
Kohai
 
Posts: 219
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: CarrierChange Breakout doesnt sent sales order object

Postby SBarnes » Mon Aug 21, 2023 6:41 pm

You can also do it in c# as well the plugin I gave you here viewtopic.php?f=26&t=2314 is doing a similar thing its just not adding parameters and calling to a separate method for example


Code: Select all
JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm sform = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm )JiwaForm;
         JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesorder = sform.SalesOrder;
         salesorder.SalesOrderLineAdded += delegate(object sender, EventArgs e, SalesOrderLine item)
         {
sform.grdCartage.LockRow(1,true);
sform.grdCartage.LockRow(2,true);
         };


could have been


Code: Select all
JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm sform = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm )JiwaForm;
         JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesorder = sform.SalesOrder;
         salesorder.SalesOrderLineAdded += delegate(object sender, EventArgs e, SalesOrderLine item)
         {
            LockGrid(sform );
         };

private void LockGrid(JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm sform)
{
    sform.grdCartage.LockRow(1,true);
    sform.grdCartage.LockRow(2,true);
}

Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: CarrierChange Breakout doesnt sent sales order object

Postby Mike.Sheen » Mon Aug 21, 2023 7:18 pm

Don't get carried away, Stuart - we can't expect people to understand what they get given and be able to apply that to different situations. That would be learning.

A drawback of the lambda function technique (whether it be VB or C#) is that the handler cannot be removed, as I pointed out in this post. Usually not a problem, but worth knowing as one day you'll waste time trying to do exactly that.
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: CarrierChange Breakout doesnt sent sales order object

Postby SBarnes » Mon Aug 21, 2023 7:27 pm

Mike.Sheen wrote:A drawback of the lambda function technique (whether it be VB or C#) is that the handler cannot be removed, as I pointed out in this post. Usually not a problem, but worth knowing as one day you'll waste time trying to do exactly that.


Yes I remember you posting that and yes I didn't know it before you did but have membered it since. :lol:
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: No registered users and 34 guests