I have an SDK based application that will export data and electronic doc to a defined folder and am trying to convert this to be used in the workflow engine as a SDK script. The bits that export the document are working fine, but I am having issues getting the CSV to work.
The expectation is that I will be generating a CSV with two lines. One with Field Names and the second with the corresponding values.
When I view the CSV created by the script, it only contains the values that I added at the bottom (originalname and path)
I believe the issue is I am getting zero results in my FieldValueCollection, so it nevers enters the loop to create line1 and line2.
Any pointers on what I am doing wrong here?
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports Laserfiche.RepositoryAccess
Imports Laserfiche.DocumentServices
Imports System.IO
Namespace WorkflowActivity.Scripting.SDKScript
Public Class Script1
Inherits RAScriptClass102
Protected Overrides Sub Execute()
'Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
Dim exportroot As String ="C:\LFExport\"
Dim csvroot As String = "C:\LFExport\CSV\"
Dim entryid As Integer = CInt(TokenReplace("%(doctoexport)"))
Try
Dim docInfo As DocumentInfo = Document.GetDocumentInfo(entryid, RASession)
Dim fvs As FieldValueCollection = docInfo.GetFieldValues()
'Dim fvs as FieldValueCollection = BoundEntryInfo.GetFieldValues()
Dim line1 As String = String.Empty
Dim line2 As String = String.Empty
'create csv lines
For i As Integer = 0 To fvs.Count - 1
Dim fieldName As String = fvs.PositionToName(i)
Dim fieldVal As Object = fvs(i)
Dim f As FieldInfo = Field.GetInfo(fieldName, RASession)
Dim formattedVal = f.ValueToString(fieldVal).Replace(",", "-")
line1 = line1 & fvs.PositionToName(i).Replace(",", "-") & ","
line2 = line2 & formattedVal & ","
Next
line1 = line1 & "originalname,path"
line2 = line2 & docInfo.GetLocalName() & "," & fullPath