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

Question

Question

How to get LF entry name and use VB script to export it with that name?

asked on May 26, 2022

I currently have this vb script that exports an entry as a PDF with the entry ID as the filename. What I need is the entry’s name. Can you help?

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

Namespace WorkflowActivity.Scripting.CopytoimagestoNetworkPathforKofaxScanningSTLIA
    '''<summary>
    '''Provides one or more methods that can be run when the workflow scripting activity is performed.
    '''</summary>
    Public Class Script1
        Inherits RAScriptClass92
        '''<summary>
        '''This method is run when the activity is performed.
        '''</summary>
        Protected Overrides Sub Execute()
            'Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session

        dim ex as new DocumentExporter


            dim doc as DocumentInfo = Document.GetDocumentInfo(integer.Parse(GetTokenValue("Entry ID")),RASession)
            dim filename as String = Document.GetDocumentInfo(GetTokenValue("Name"),RASession)
            ex.ExportPdf(doc, doc.AllPages,PdfExportOptions.None, "\\fsstl06\userdirs\Scanning\Emma_Securian\IA\STL\" & GetTokenValue("Name") & ".pdf")

        End Sub
    End Class
End Namespace

I've tried variations in which the filename variable was put in there, like this:

dim doc as DocumentInfo = Document.GetDocumentInfo(integer.Parse(GetTokenValue("Entry ID")),RASession)
            dim filename as String = Document.GetDocumentInfo(GetTokenValue("Name"),RASession)
            ex.ExportPdf(doc, doc.AllPages,PdfExportOptions.None, "\\fsstl06\userdirs\Scanning\Emma_Securian\IA\STL\" & filename & ".pdf")

and this...

          dim doc as DocumentInfo = Document.GetDocumentInfo(integer.Parse(GetTokenValue("Entry ID")),RASession)
            dim filename as DocumentInfo = Document.GetDocumentInfo(GetTokenValue("Name"),RASession)
            ex.ExportPdf(doc, doc.AllPages,PdfExportOptions.None, "\\fsstl06\userdirs\Scanning\Emma_Securian\IA\STL\" & GetTokenValue("Name") & ".pdf")

These all result in a 9001 error of "entry not found" . I don't have a lot of VB experience, surely it's something easy. Thanks for any help.

0 0

Replies

replied on May 26, 2022

Dim Name As String = CType( doc, EntryInfo).Name
should work

0 0
replied on May 26, 2022 Show version history

Paul, you're trying way too hard.  This should be all you need.  This saves to a folder on the workflow server; you change it to the path you need.

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

Namespace WorkflowActivity.Scripting.SDKScript
    '''<summary>
    '''Provides one or more methods that can be run when the workflow scripting activity is performed.
    '''</summary>
    Public Class Script1
        Inherits RAScriptClass104
        '''<summary>
        '''This method is run when the activity is performed.
        '''</summary>
        Protected Overrides Sub Execute()
            'Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
        dim ex as new DocumentExporter
        Dim filename As String = BoundEntryInfo.Name & ".pdf"
        Dim doc As DocumentInfo = CType(BoundEntryInfo, DocumentInfo)
        ex.ExportPdf(doc, doc.AllPages, PdfExportOptions.None, "C:\WorkflowAdminFiles\" & filename)
        End Sub
    End Class
End Namespace

 

0 0
replied on May 27, 2022

It all came down to me using "Name" vs "Entry Name". The LF desktop client uses "Name" for the "Entry Name", so I used that thinking it would work. To others, use "Entry Name" to get it right the first time. :)

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

Sign in to reply to this post.