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

Question

Question

get template field names

asked on March 19, 2014

I am trying to Query repository for the names of the fields associated with a particular template, say 'General'. Using RA, this is not working, any ideas??

 

 Dim MyTemplateInfo as TemplateInfo=Template.GetInfo("General",session)

do until i=MyTemplateInfo.FieldCount

MyVar=MyTemplateInfo.Item(i).Name

'More code here..

i+=1

loop

 

But I get this error message...

Index was out of range.Must be non-negative and less that the size of the collection..

0 0

Answer

SELECTED ANSWER
replied on March 19, 2014 Show version history

Try iterating directly through the TemplateInfo's Fields property. Something like this:

Dim MyTemplateInfo As TemplateInfo
MyTemplateInfo = Template.GetInfo("General",session)
For Each field As FieldInfo In MyTemplateInfo.Fields
    ' Use the FieldInfo object as you like
    Console.WriteLine(field.Name)
Next

EDIT: I previously included some Refresh calls here, but they aren't necessary so I removed them.

0 0
replied on March 19, 2014

Thank you! Worked great!

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.