You are viewing limited content. For full access, please sign in.

Question

Question

SDK Search with Toolkit RA

asked on January 13, 2016 Show version history

[Edited]

I'm attempting to add a file to the repository using Import Agent, then 'find' that file once it hits the repository. I'm able to get the file into the Repository without any issues using a LST file; but when I search for the new electronic file to get it's EntryID, it doesn't find it. I either get the same EntryID back (37183) or an error: Specified argument was out of the range of valid values. Parameter name: rowNumber.

I was wondering if you could check out my code to see if I'm doing something wrong, or if there is some sort of lag between adding a new file into LF and when it can be searched using Toolkit...?


I'm passing in the Template Name, Template Fields (as String Array), and Template Values (as String Array).

    Public Function searchForEntryID(ByVal templateName As String, ByVal templateFields() As String, ByVal templateValues() As String) As String

        Dim lfResultList As SearchResultListing                 'Search Result List
        Dim entryID As String = ""                              'Holds EntryID
        Dim lfQuery As String = ""                              'Holds LF Query
        Dim queryTemplate As String = "[" & templateName & "]:" 'Holds LF Query String
        Dim queryField As String = ""                           'Holds individual Query Field Names
        Dim queryValue As String = ""                           'Holds individual Query Values

        'For 0 to number of values -1
        For tField As Integer = 0 To templateValues.Length - 1

            Try
                'Set queryField to the template field name
                queryField = "[" & templateFields(tField) & "]"

                'If the name contains 'Date' Then
                If queryField.Contains("Date") Then
                    'Set queryValue to include only that date
                    queryValue = ">=""" & templateValues(tField) & """, <=""" & templateValues(tField) & """"
                Else
                    'Set queryValue to the corresponding value of the field name
                    queryValue = "=""" & templateValues(tField) & """"
                End If

                'Add Query Template, Field Name, and Value to lfQuery
                lfQuery &= "{" & queryTemplate & queryField & queryValue & "} & "
            Catch ex As Exception
                Exit For
            End Try
        Next

        'Trim the end if ends with ' & '
        If lfQuery.EndsWith(" & ") Then lfQuery = lfQuery.Remove(lfQuery.Length - 3).Trim()

        'Search LF and return to lfResultList
        lfResultList = searchLaserfiche(lfQuery)

        'Assign the searchResult entry id to entryID
        entryID = lfResultList.GetEntryInfo(1).Id

        'Return the Entry ID
        Return entryID

    End Function


    Private Function searchLaserfiche(ByVal searchParams As String) As SearchResultListing
        'Create search variable using the session
        Dim lfSearch As New Search(mySess)
        'Search parameters used are passed via the 'searchParams' parameter
        lfSearch.Command = searchParams

        lfSearch.Run()  'Run the query

        'Settings for SearchResultListing
        Dim searchSettings As SearchListingSettings = New SearchListingSettings()

        'SearchResultListing of all hits in the search
        Dim searchResults As SearchResultListing = lfSearch.GetResultListing(searchSettings)
        Return searchResults
    End Function

 

0 0

Answer

SELECTED ANSWER
replied on January 14, 2016

I guess it would help if I was accessing the correct Repository while searching...

0 0

Replies

replied on January 13, 2016

Is your entry actually named "----"? That seems incorrect and, even if it is correct, since it's a hardcover name you'd return the same entry each time (as it sounds like is happening).

1 0
replied on January 13, 2016 Show version history

The entry being searched is passed through the 'searchParams' from the 'searchForEntryID' Function above. I was testing the search earlier with another entry and those were the parameters I had searched on to make sure the format was correct. That search is commented out and doesn't run.

Updating that line for clarity. Thanks!

0 0
replied on January 20, 2016

Like you mention, I think you are running the search before the document is available. Try calling your method in a loop so that it retries the search if lfResultList.RowCount == 0.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.