[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