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

Question

Question

Using a multi-value token in an SDK script

SDK
asked on October 5, 2015

Hi there,

I have a simple SDK script that searches for documents, gets its field values then writes them in a .csv file, like so:

        Try
            Dim dPath As String = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
            Dim csvWriter As New System.IO.StreamWriter(dPath & "\temp.csv")
            Dim headerRow As String
            Dim dataRow As String
            Dim csvData As New StringBuilder
                headerRow = "Field Value 1,Field Value 2"
                csvData.AppendLine(headerRow)
            Dim Search As LFSearch = me.Database.CreateSearch()
                Search.Command = "{search syntax}"
                Search.BeginSearch(True)
            Dim SearchHits As ILFCollection = Search.GetSearchHits()
            If SearchHits.Count > 0 Then
            For Each Hit As LFSearchHit In SearchHits
                Dim Doc As LFDocument = Hit.Entry
                Dim Fd As LFFieldData = Doc.fielddata
                Dim Fieldval1 As String = Fd.Field("Field 1")
                Dim Fieldval2 As String = Fd.Field("Field 2")
                dataRow = Fieldval1 & "," & Fieldval2
                csvData.AppendLine(dataRow)
            Next
            Else
                dataRow = "No records to display"
                csvData.AppendLine(dataRow)
            End If
                csvWriter.Write(csvData)
                csvWriter.Close
                csvWriter = Nothing
                csvData = Nothing
                Search.Dispose()
        Catch Ex As Exception
        End Try

What I want to do now, is remove the search syntax from the script, and instead use a (Workflow) Search activity to search for the documents, then using a For Each Entry activity, put the search results in a multi-value token, then use the multi-value token in the script (instead of the hits from the now removed search syntax).

If this is possible, any example on how to do it will be very much appreciated. Thank you.

0 0

Answer

SELECTED ANSWER
replied on October 5, 2015

That would be more inefficient since you would be opening and closing the CSV file for each document.

1 0

Replies

replied on October 7, 2015

Hi Miruna,

 

Yes I believe I do understand what you mean. Thank you for your response.

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

Sign in to reply to this post.