warehouse transfer business logic object problem  Topic is solved

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

warehouse transfer business logic object problem

Postby perry » Mon Jan 18, 2016 4:29 pm

Hi,
Jiwa 7.0.149

I'm trying to split warehouse transfer before activation, however, find some weird behavior between objects.

The function below illustrate the problem that I'm having (full plugin attached).
Code: Select all
Private Sub TransferActivateBefore(ByRef Cancel As Boolean)
      Dim recid As String
      recid = WHTrans.RecID
       
      msgbox("Existing Transfer No.: " & WHTrans.TransferNo) 'this returns correct No.
      NewWHTrans = JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic(Of JiwaWhouseTransfer.clsWarehouseTransfer)(Nothing)
      msgbox("Existing Transfer No. (after init new object): " & WHTrans.TransferNo) 'this return blank No., as it should return the existing transfer No.
      
      WHTrans.Read(recid)
      msgbox("New Transfer No. (after read): " & NewWHTrans.TransferNo) 'this returns transfer no. from existing transfer object, as it should return blank transfer No.
      
      Throw New JiwaApplication.Exceptions.PluginAbortException("abort testing")
    End Sub


Basically, I have 2 warehouse transfer objects (existing and new transfer). However, they are somehow reference to each other, so I have 2 instances of the same transfer.
Attachments
Plugin Test Transfer Split.rar
(4.26 KiB) Downloaded 657 times
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: warehouse transfer business logic object problem  Topic is solved

Postby Mike.Sheen » Mon Jan 18, 2016 5:13 pm

perry wrote:however, find some weird behavior between objects.
...
they are somehow reference to each other, so I have 2 instances of the same transfer.


If you change your Setup method to this, It behaves as I think you intended:

Code: Select all
Public Sub Setup(ByVal JiwaBusinessLogic As JiwaApplication.IJiwaBusinessLogic, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaBusinessLogicPlugin.Setup      
   If WHTrans Is Nothing Then ' Prevent creating of the split transfer in our TransferActivateBefore creating another transfer and possible recursing infinitely
      WHTrans = TryCast(JiwaBusinessLogic, JiwaWhouseTransfer.clsWarehouseTransfer)
      
      If Not WHTrans Is Nothing Then
         AddHandler WHTrans.TransferActivateBefore, AddressOf TransferActivateBefore
      End If
   End If       
End Sub


Because we create an instance of the class BusinessLogicPlugin ONCE - at login time, and then we invoke the Setup method of that same instance whenever the BusinessLogicFactory is used to create a new instance of the business logic, your Setup method was being invoked by the 2nd Warehouse transfer you created in the TransferActivateBefore handler and overwriting the WHTrans variable with the 2nd instance.

Mike

EDIT: I should add that if the Warehouse Transfer event TransferActivateBefore included the sender (the instance of the Warehouse Transfer business logic), then you would not need to store an instance into your local WHTrans variable, and the problem would have been avoided altogether. I've added bug 12402 to do just that - but for now the above work-around should suffice.
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: Custom field lookup to locate items on a specific sales

Postby perry » Tue Jan 19, 2016 1:30 pm

Hi Mike,

Thanks, that fixed my problem.
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest