Custom Search Sk Transfer Serial Search  Topic is solved

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

Custom Search Sk Transfer Serial Search

Postby 2can2 » Wed Jan 20, 2016 7:51 am

Hi, I am trying to add a custom search in the Stock transfer form when transferring a Serialised item but can't find the Name of the search to use? Using jswStockTransfer, tried several other combinations but I am not sure where I could find these references and also filter nos??
As below :
With JiwaApplication.Manager.Instance.Search
If .CurrentSearchMode = JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswStockTransfers Then

Thanks.
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25

Re: Custom Search Sk Transfer Serial Search

Postby Mike.Sheen » Thu Jan 21, 2016 10:41 am

2can2 wrote:Hi, I am trying to add a custom search in the Stock transfer form when transferring a Serialised item but can't find the Name of the search to use? Using jswStockTransfer, tried several other combinations but I am not sure where I could find these references and also filter nos??
As below :
With JiwaApplication.Manager.Instance.Search
If .CurrentSearchMode = JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswStockTransfers Then

Thanks.


Which search are you wanting to extend? The search to choose the inventory item, or the search to choose the SOH line when performing a transfer From a part (not external)? Or is it the search for the To Part?

The search of the SOH lines when transferring From a part is as follows:

Code: Select all
Private Function SearchSOH(Optional ByVal FilterSQL As String = "") As List(Of String)
   For Each existingLine As JiwaStockTransfer.Line In StockTransfer.Lines
      If FilterSQL.Trim.Length > 0 Then
         FilterSQL = FilterSQL & " AND [LinkID] <> " & JiwaApplication.Manager.Instance.Database.FormatChar(existingLine.FromPartInventorySOHID)
      Else
         FilterSQL = " [LinkID] <> " & JiwaApplication.Manager.Instance.Database.FormatChar(existingLine.FromPartInventorySOHID)
      End If
   Next existingLine

   With JiwaApplication.Manager.Instance.Search
      .Clear()
      .SQLWhereCondition = FilterSQL
      .SetDefaultSearch(JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswStockOnHand)
      .UsePinBoard = True
      Dim Results As List(Of String) = New List(Of String)
      If .Show(Me) = Windows.Forms.DialogResult.OK Then
         For myLoop As Integer = 1 To .Results.Count
            Results.Add(.Results(myLoop).Fields(1).FieldValue)
         Next
         Return Results
      Else
         Return Results
      End If
   End With
End Function


So, the searchmode is jswStockOnHand in that case.

The search for the From part and To Part is as follows:
Code: Select all
Private Function SearchInventory(ByVal SearchText As String) As String
   Dim AOption As JiwaApplication.JiwaSearch.SearchOption
   Dim WorkStr As String

   With JiwaApplication.Manager.Instance.Search
      .Clear()
      .SetDefaultSearch(JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswInventory)
      .FilterNo = 36
      .CurrentOption = 1
      .Caption = "Inventory"
      .UsePinBoard = False
   End With
   
... Lots more custom search options are added here - excluded for readability
End Function


So that's search mode jswInventory and FilterNo 36.
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 Search Sk Transfer Serial Search

Postby 2can2 » Thu Jan 21, 2016 12:32 pm

Hi, Thanks Mike for the reply.
It is the search to choose the SOH line when performing a transfer From a part, sorry for not clarifying. many thanks.
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25

Re: Custom Search Sk Transfer Serial Search

Postby 2can2 » Thu Jan 21, 2016 9:25 pm

Hi Mike, I haven't had time to figure out how you sample Functions work so used the base code I have used for other custom searches in V7.
It works fine except I don't know how to restrict the display to ONLY the IN_SOH records matching the InventoryID we have already selected.
This is in Stock Transfers From Part No, Enter Part No which is serial and the Search window pops up ? Can you help please - code below:

Private Sub Search_Showing(sender As Object, e As System.EventArgs)
With JiwaApplication.Manager.Instance.Search
'' Msgbox(.currentsearchmode)
If .CurrentSearchMode = JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswStockOnHand Then
'' Reference the Search Module!!!!
Dim AOption As New JiwaApplication.JiwaSearch.SearchOption
With AOption
.Title = "Straw ID ,Tank"
.SQLStr = "SELECT IN_SOH.LinkID, IN_Soh.InventoryID, SerialNo, BinLocationDesc, DateIn, QuantityLeft, QuantityIn " &
"FROM IN_Main JOIN IN_SOH On IN_Main.InventoryID = IN_SOH.InventoryID " & _
"WHERE (IN_SOH.InventoryID = JiwaApplication.Manager.Instance.Database.Current.InventoryID) " &
" And (QuantityLeft <> 0) And (IN_SOH.IN_LogicalID = 'ZZZZZZZZZZ0000000000') "
'' And (IN_SOH.InventoryID = IN_Main.InventoryID)
.OrderBy = "ORDER BY IN_SOH.SerialNo"
.AddColumn ("LinkId", vbString, "", 0, 0)
.AddColumn ("InventoryID", vbString, "", 0, 1)
.AddColumn ("Serial No", vbstring, "", 15, 2)
.AddColumn ("Tank ID", vbstring, "", 15, 3)
.AddColumn ("Date In", vbDate, "", 15,4)
.AddColumn ("Qty Left", vbInteger, "", 6, 5)
.AddColumn ("Qty In", vbInteger, "", 6, 6)
End With

.Options.Add(AOption)
End If
End With
End Sub

Cheers
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25

Re: Custom Search Sk Transfer Serial Search  Topic is solved

Postby Mike.Sheen » Fri Jan 22, 2016 11:31 am

This is a bit tricky, as the search needs to be given the query filter containing the inventory id - and you can't easily inject that from within the Search_Showing of the JiwaApplication.Manager.

So, instead you will need to intercept the grid button click and change events (those are the two places where that SOH search is displayed from the stock transfer form), and basically replicate what the form already does, then throw a client cancelled to stop the form trying to handle the buttonclick or change after you already have.

It's a lot of work and leaves your plugin exposed to issues if we change that form in the future.

Attached is a plugin which does what you need.
Attachments
Plugin Stock Transfer custom SOH search.xml
Sample plugin
(42.05 KiB) Downloaded 609 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

Re: Custom Search Sk Transfer Serial Search

Postby 2can2 » Tue Feb 02, 2016 6:43 pm

Thanks Mike. I would never have figured that code especially seeing it all relates to the From Part Search but it does exactly what I needed when it drops into the Serial Search box! Thanks again.
I will obviously make a note if this Serial Search form changes in the future!
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests