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

Question

Question

Export Report CSV

asked on June 11, 2020

Is there a way to export a report like the screenshot in the attachments? It is a csv file and it has all of the metadata separated by a "|" and the date is in UTC format. This is for import to Box. Any help is appreciated, thanks.

2020-06-11 11_13_16-Docunav_Schwab_Metadata_Unchanged  -  Read-Only - Excel.png
0 0

Answer

SELECTED ANSWER
replied on June 11, 2020 Show version history

You can use a workflow and sdk script to generate a csv.

Set your header manually and popule your body using a search request.

 

 

1°) Create your CSV File using SDK Script (C# .NET)

namespace WorkflowActivity.Scripting.CreateCSVFileandHEADER
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;

    /// <summary>
    /// Offre une ou plusieurs méthodes qui peuvent être exécutées au moment de l'exécution de l'activité de scriptage du flux de travail.
    /// </summary>
    public class Script1 : ScriptClass90
    {
        /// <summary>
        /// Cette méthode est exécutée quand l'activité est effectuée.
        /// </summary>
        protected override void Execute()
        {
            // Path Destination
            string fpath = "C:\\Users\\yourname\\Desktop\\";

            // if Path doesn't exist, create it
            if(!System.IO.Directory.Exists(fpath))
                System.IO.Directory.CreateDirectory(fpath);

            // Name file
            fpath = System.IO.Path.Combine(fpath, "myfile.csv");

            // Set the HEADER and add a linebreak
            System.IO.File.WriteAllText(fpath, "col1|col2|col3" + Environment.NewLine);
        }
    }
}

2°) Search all your files in Laserfiche and retrieve the fields you want

3°) Do a loop

4°) Set your col1's value, col2's value ...

5°) Add your value to your CSV

namespace WorkflowActivity.Scripting.AddLinetoCSV
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;

    /// <summary>
    /// Offre une ou plusieurs méthodes qui peuvent être exécutées au moment de l'exécution de l'activité de scriptage du flux de travail.
    /// </summary>
    public class Script1 : ScriptClass90
    {
        /// <summary>
        /// Cette méthode est exécutée quand l'activité est effectuée.
        /// </summary>
        protected override void Execute()
        {
            // Path Destination
            string fpath = "C:\\Users\\yourname\\Desktop\\";

            // Name file
            fpath = System.IO.Path.Combine(fpath, "myfile.csv");

            // Add the BODY and a linebreak
            System.IO.File.AppendAllText(fpath, Convert.ToString(GetTokenValue("Col1"))+"|"+Convert.ToString(GetTokenValue("Col2"))+"|"+Convert.ToString(GetTokenValue("Col3")) + Environment.NewLine);
        }
    }
}

 

Then "Voilà"

 

 

1 0
replied on June 11, 2020

Thanks a lot for your help Olivier!

0 0

Replies

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

Sign in to reply to this post.