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

Question

Question

create a list of all templates in Laserfiche from RA

SDK
asked on October 3, 2014

I am having an issue trying to build a list of all the templates in laserfiche.

I can access the templateinforeader but I can not enumerate the list

Does anyone have an example?

templateList = Template.EnumAll(mySess)
Dim TemplateCount As Integer = templateList.Count
Dim Myenumerator As IEnumerator = templateList.GetEnumerator

While Myenumerator.MoveNext
     Me.CBTemplate.Items.Add(Myenumerator.Current.ToString)
End While

the above snippet stops at the while statement what am I doing wrong?

 

0 0

Answer

SELECTED ANSWER
replied on October 3, 2014 Show version history

here is how I do it.

        CBTemplate.Items.Clear()
        Using TemplateEnum As TemplateInfoReader = Template.EnumAll(mySess)
            For Each TempInfo As TemplateInfo In TemplateEnum
                ' Use the TempInfo to get what you need
                CBTemplate.Items.Add(TempInfo.Name)
            Next
        End Using

 

4 0

Replies

replied on October 3, 2014

Hi Andrew,

 

Does this help?

 

https://support.laserfiche.com/forums.aspx?Link=viewtopic.php%3ft%3d15152%26amp

 

yes

1 0
replied on October 3, 2014

Bert's solution is the one i'd go with. But for why your while loop stops, I think you have to call Read first on the TemplateInfoReader.

0 0
replied on October 3, 2014 Show version history

I just a method close to both you and Bert. I create a List, loop through the TemplateReaderInfo (as reader) and grab the template name. I've also used a slightly more involved version to grab the template's fields as well.

Here's my basic method, for .NET 4.0/4.5

    Private Sub GetTemplateList()
        Dim tmpList As New List(Of String)

        Using reader As TemplateInfoReader = Template.EnumAll(CurrentSession)
            reader.ToList.ForEach(Sub(tmpInfo)
                                      tmpList.Add(tmpInfo.Name)
                                  End Sub)
        End Using

    End Sub

For earlier versions, replace the ToList.ForEach loop with the following

            For Each tmpInfo As TemplateInfo In reader
                tmpList.Add(tmpInfo.Name)
            Next tmpInfo

 

 

replied on October 6, 2014

Hello Andrew,

 

If your question has been answered, please remember to select the "This answered my question" button below the appropriate post!  If you have any other questions, just ask and we'll take another look!

 

Thanks!

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

Sign in to reply to this post.