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

Question

Question

Adding YEAR to CSV Report Name

asked on August 10, 2017

I have a workflow that creates a CSV file at the end. I would like to know how I can add the current year to the end of the report name so it is called E-BOOK INDEX 2017.csv and doesn't need to be hard coded.

The workflow is creating a Year token:

Here's the "Write csv file to network drive "script. I know nothing about scripting. What do I need to do to add the year token when naming the file?

namespace WorkflowActivity.Scripting.Writecsvfiletonetworkdrive
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : RAScriptClass92
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {
            // overwriting existing file with same name
            System.IO.File.Copy(GetTokenValue("csvpath").ToString(), @"\\adom\tn\Groups\Engineering\E-documents\LF Test System E-BOOK INDEX YEAR.csv", true);
        }
    }
}

 

0 0

Answer

SELECTED ANSWER
replied on August 10, 2017

Replace the end of your naming/storing string to put the token value before the .csv.

 

\LF Test System E-Book Index Year " & GetTokenValue ("insert token name here") & ".csv"

0 0
replied on August 10, 2017

Update:  When using C#, replace the & with +.

0 0

Replies

replied on August 10, 2017

I changed it to:

  \LF Test System E-BOOK INDEX" & GetTokenValue ("YearToken_CurrentYearToken") & ".csv", true);

But I get the following error when trying to publish:

  Operator '&' cannot be applied to operands of type 'string' and 'object'

0 0
replied on August 10, 2017

You have "csvpath" as a token in the front on the line.  Is this created in the workflow or earlier in the script?

 

Here is how I get token into my csv name.

 

Protected Overrides Sub Execute()
            dim filepath as String = "\\*servernamehere*\data\ITS\Secure\Imaging\LandLinkCSVFiles\Book - " & GetTokenValue ("BookTypeToken") & GetTokenValue("RetrieveFieldValues_Book Number") & ".csv"

0 0
replied on August 10, 2017

Replaced the two & with + (using C#) and I was able to publish with no errors. Thanks!

0 0
replied on August 10, 2017

Great!

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

Sign in to reply to this post.