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

Question

Question

Export Document with dynamic Entry ID

asked on February 14, 2017

I am looking for some help on a script I wrote that exports a file to a folder outside of Laserfiche.  The goal here is to take an electronic file (.txt) and export it to a folder location.  

Here is my code:

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


    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : ScriptClass90
    {
        protected override void Execute()
 {
            RepositoryRegistration myRepoReg = new RepositoryRegistration("myServer", "myRepository");
            Session mySess = new Session();
            mySess.LogIn("wfuser", "myPassword", myRepoReg); //uses Laserfiche authentication
            int curEntry = GetTokenValue("Entry ID");
            DocumentInfo DI = Document.GetDocumentInfo(curEntry, mySess);
            DocumentExporter DE = new DocumentExporter();
            DE.ExportElecDoc(DI, "//prodlfqf//Attachments//Signed" + DI.Extension);
            mySess.Close();
        }
	}
}

The workflow is returning an error that 'Entry not found [9001]' and I'm not sure why it cannot find the entry.  I'm starting the workflow with an entry ID and it still returns this message.  Note: when I replace 'curEntry' with '1234' the file is exported successfully, but I want it to be more dynamic so it will export whatever file initiated the workflow.  

Any help is much appreciated!  

Nate

0 0

Replies

replied on February 15, 2017

here what I have use to export file to pdf but that should be similar

 

but I used

DocumentInfo DI = (DocumentInfo)this.BoundEntryInfo;

to get the current document entry

and also to use RAScriptClass100, you do not need to create a session, it will take the workflow session

namespace WorkflowActivity.Scripting.SDKScript
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
    using Laserfiche.DocumentServices;
    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : RAScriptClass100
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {
            // Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session

            try
            {
//get the document info for the current entry
                DocumentInfo DI = (DocumentInfo)this.BoundEntryInfo;
                DocumentExporter DE = new DocumentExporter();
                //DE.IncludeAnnotations = true; // convert Laserfiche annotations into Adobe Acrobat annotations.
                DE.CompressionQuality = 25;
                DE.ExportPdf(DI, DI.AllPages, PdfExportOptions.IncludeText , "c:\\testagropur\\" + GetTokenValue("ForEachEntry_CurrentEntry_Name").ToString() + ".pdf");
            }
            catch (Exception ex)
            {
               throw new LaserficheRepositoryException ("Script threw exception", ex);
            }
        }
    }
}

 

0 0
replied on February 15, 2017

I'm guessing you either don't have a starting entry for this workflow or you're not specifying one when you test the script.

Other than that, Rene is right. Don't use a plain Script activity with custom references. Use the built-in SDK script activity and its connection.

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

Sign in to reply to this post.