Page 1 of 1

ProcessSnapShotCreated

PostPosted: Tue Jan 28, 2020 5:31 pm
by Ernst
Am trying to get to the snapshot created logic in Auto BO process. On JIWA721.

Found this code on the forum. But the AddHandler _boProcess.ProcessSnapShotCreated, says Process is not an event of JiwaBOProcess.StdFunctions, Can anybody help on how to find AddHandler _boProcess.ProcessSnapShotCreated

Thx

Public Sub Setup(ByVal JiwaBusinessLogic As JiwaApplication.IJiwaBusinessLogic, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaBusinessLogicPlugin.Setup
_boProcess = TryCast(JiwaBusinessLogic, JiwaBOProcess.StdFunctions)
If _boProcess Is Nothing Then Return '

AddHandler _boProcess.ProcessSnapShotCreated, AddressOf BoProcess_SnapshotCreated

End Sub

Private Sub BoProcess_SnapshotCreated(InvoiceID As String, InvoiceHistoryID As String)
msgbox ("in BoProcess_SnapshotCreated")
End Sub

Re: ProcessSnapShotCreated  Topic is solved

PostPosted: Tue Jan 28, 2020 5:56 pm
by Mike.Sheen
The logic for processing backorders now lives in the sales order itself.

So, the sales order business logic has a method named BackorderProcess which is what gets invoked by the backorder processing form.

This BackorderProcess method raises an event, BackorderProcessStart and then proceeds to do its' thing - including, if necessary, making a new snapshot and raising the event CreatedNewSnapshot.

So, just add a handler for the BackorderProcessStart and in there add a handler for the CreatedNewSnapshot event.

Sample plugin doing this is attached.

Re: ProcessSnapShotCreated

PostPosted: Tue Jan 28, 2020 6:41 pm
by Ernst
Worked great thx. Converted in good old fashioned stuff..

Public Sub Setup(ByVal JiwaBusinessLogic As JiwaApplication.IJiwaBusinessLogic, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaBusinessLogicPlugin.Setup
If TypeOf JiwaBusinessLogic Is JiwaSales.SalesOrder.SalesOrder Then
Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(JiwaBusinessLogic, JiwaSales.SalesOrder.SalesOrder)

AddHandler salesOrder.BackorderProcessStart, AddressOf SalesOrder_BackorderProcessStart
End If
End Sub
Private Sub SalesOrder_BackorderProcessStart(sender As Object,ByVal InvoiceLineID As String, ByVal QuantityToFulfill As Decimal)
Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
AddHandler SalesOrder.CreatedNewSnapshot, AddressOf SalesOrder_CreatedNewSnapshot
End Sub
Private Sub SalesOrder_CreatedNewSnapshot(sender As Object, e As System.EventArgs)
Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
msgbox ("in Create new snapshot-Mike")
Dim SalesOrderH As JiwaSales.SalesOrder.SalesOrderHistory = salesOrder.SalesOrderHistorys(salesorder.CurrentHistoryNo)
' // If we Get here, Then it's because the backorder process ended up creating a new snapshot for the sales order
' // We don't get in here when a new snapshot is created manually because we only add a handler for the CreatedNewSnapshot event inside a BackorderProcessStart handler.
End Sub

Re: ProcessSnapShotCreated

PostPosted: Sat Feb 01, 2020 5:51 pm
by Mike.Sheen
Thanks for sharing the code converted to VB.NET - I'm sure it will help some people.

On that note, I think it's time you were educated on the Code tag which you can use in your posts to post code snippets so they are formatted correctly.

The toolbar above the post content area has a button labelled "Code":
CodeButton.PNG
CodeButton.PNG (5.38 KiB) Viewed 419 times


When you click that, it adds the [code] and [/code] BBCode tags. Text you place between those tags will be formatted as such:

Code: Select all
Public Sub Setup(ByVal JiwaBusinessLogic As JiwaApplication.IJiwaBusinessLogic, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaBusinessLogicPlugin.Setup
   If TypeOf JiwaBusinessLogic Is JiwaSales.SalesOrder.SalesOrder Then
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(JiwaBusinessLogic, JiwaSales.SalesOrder.SalesOrder)
      AddHandler salesOrder.BackorderProcessStart, AddressOf SalesOrder_BackorderProcessStart
   End If
End Sub

Private Sub SalesOrder_BackorderProcessStart(sender As Object,ByVal InvoiceLineID As String, ByVal QuantityToFulfill As Decimal)
   Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
   AddHandler SalesOrder.CreatedNewSnapshot, AddressOf SalesOrder_CreatedNewSnapshot
End Sub

Private Sub SalesOrder_CreatedNewSnapshot(sender As Object, e As System.EventArgs)
   Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
   msgbox ("in Create new snapshot-Mike")
   Dim SalesOrderH As JiwaSales.SalesOrder.SalesOrderHistory = salesOrder.SalesOrderHistorys(salesorder.CurrentHistoryNo)
   ' // If we Get here, Then it's because the backorder process ended up creating a new snapshot for the sales order
   ' // We don't get in here when a new snapshot is created manually because we only add a handler for the CreatedNewSnapshot event inside a BackorderProcessStart handler.
End Sub


It makes it more readable - which can only be a good thing!