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

Question

Question

How do you export data collected in a form to a csv file?

asked on January 17, 2014

I want to collect information in a Laserfiche Form and then export some of the form field values as a comma separated value  file. Is it possible to use tools in Laserfiche Workflow to do this?  If so, which tool or tools?

0 0

Answer

APPROVED ANSWER
replied on January 20, 2014

You can export the results of business processes in Forms directly from the Results page.

 

  1. To do so, go to the Results page and click the Change column display button. Configure the columns to display the process and field information you're interested in, and then click Save.
  2. If you'd like to filter the results by step, status, form, or date, click the Filter button and apply the desired filters to the list of results.
  3. When the information appears the way you want it on the Results page, click the Download button. Specify the file type (CSV or XLSX) and whether to include or ignore any filtering shown on the results page. Click Download to download the results.

 

 

0 0

Replies

replied on January 17, 2014 Show version history

John,

 

You can use the 'SDK Script' activity to accomplish this.  A couple of caveats; 

 

First; the account that workflow is running under _must_ have appropriate Windows permissions to write the CSV file to the target folder.  This is generally not a problem when you are trying to write a file to the local server and workflow is running under the local system account, but it will be a problem if you are trying to write to another server share and workflow is running under a domain account that does not have permissions to the target folder

 

Second; the routines to write CSV files can get complex if the row data contains delimiter characters (commas in this case).  The code below is about as simple as it can get because it assumes that the row data does not contain any commas.

 

Finally, in the example below I am 'hard coding' the header row and data row values.  In a real world application you will most likely be storing the document metadata field values as tokens and then referencing them in the script to build the header and/or data row strings.  (If you need help with referencing those tokens in your script then let me know)

 

Here is the code;

 

        Protected Overrides Sub Execute()
            
            'Wrap the code in a Try/Catch to catch any errors...
            Try
               'Instantiate a new streamwriter...
                Dim csvWriter As New System.IO.StreamWriter("C:\TestData\Test.csv")
                Dim headerRow As String 'Will hold the header row values
                Dim dataRow As String   'Will hold the data row values
                Dim csvData As New StringBuilder    'We will append all of the data to this string object

                'Here is the header row...
                headerRow = "Column Name 1,Column Name 2,Column Name 3,Column Name 4"
                csvData.AppendLine(headerRow)

                'Here is the first data row...
                dataRow = "Value 1, Value 2, Value 3, Value 4"
                csvData.AppendLine(dataRow)

                'Here is the second data row...
                dataRow = "Value 1, Value 2, Value 3, Value 4"
                csvData.AppendLine(dataRow)

                'Now write the CSV file and close the streamwriter...
                csvWriter.Write(csvData)
                csvWriter.Close

                'Cleanup...
                csvWriter = Nothing
                csvData = Nothing

            Catch ex As Exception
                'Send any error messages to workflow so they can be tracked...
                WorkflowApi.TrackError(ex.message)

            End Try

        End Sub

Let me know if this helps!

1 0
replied on January 17, 2014

I don't know about using Laserfiche Workflow for this. 
 

You can view all of the  Results and create Reports in Forms when you are managing the process. 

0 0
replied on January 18, 2014

Alternatively, you can have Laserfiche Forms trigger a Workflow and use the "Retrieve Laserfiche Forms Content" activity in Workflow to extract all the field data. Once the data is in Workflow, you can convert it to whatever format you need, such as .csv, or even write the entries to SQL.

 

I'm curious, how are you intending to use the .csv data John? If you're planning to archive the data or use it to trigger another process, you should be able to do all of that from within Workflow to consolidate your process and make it more manageable.

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

Sign in to reply to this post.