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

Question

Question

Generate a list of all fields in a repository

SDK
asked on April 8, 2015

Greetings,

I am trying to generate a list of all fields in a repository and place them in a combo box.  I am using c#.  I want the user to be able to select fields as they move through my application. I can use either RA, or Com.

 

Thanks for the help

Phil

0 0

Replies

replied on April 10, 2015 Show version history

Here is how I would do it

                if (String.IsNullOrEmpty(sLFTemplate))
                {
                    // No template so get all fields
                    using (FieldInfoReader fReader = Field.EnumAll(CurSession))
                    {
                        while (fReader.Read())
                        {
                            FieldInfo fld = fReader.Item;
                            cmbField.Items.Add(fld.Name);
                        }
                    }
                } else {
                    // get fields from specified template
                    TemplateInfo tmp = Template.GetInfo(sLFTemplate, CurSession);
                    var AllFields = tmp.Fields.GetEnumerator();
                    while (AllFields.MoveNext())
                    {
                        try
                        {
                            FieldInfo fld = (FieldInfo)AllFields.Current;
                            cmbField.Items.Add(fld.Name);
                        }
                        catch
                        {
                        }
                    }
                }
1 0
replied on April 8, 2015

Using RA, you would call Field.EnumAll which returns a FieldInfoReader object.

0 0
replied on April 9, 2015

Robert,

Thanks for responding! I can't seem to figure out the foreach loop syntax.  I tried to loop through based on the count, but it shows me the same field information. I know I am missing something simple.  Any additional assistance would be great.

  	    cmbLFFieldsList.Items.Clear();
            FieldInfoReader fir  = Field.EnumAll(mySess);
            int fdCount = fir.Count();

            for (int i = 0; i < fdCount; i++)
            {
                string fdName = fir.Item.Name.ToString();
                cmbLFFieldsList.Items.Add(fdName);
                Console.WriteLine("Current field name = " + fdName);
                
            }

 

0 0
replied on April 9, 2015

Here is a sample:

using (FieldInfoReader reader = Field.EnumAll(mySess))
{
    while (reader.Read())
    {
        FieldInfo theField = reader.Item;
        // Do something with the field here
     }
}

 

1 0
replied on April 9, 2015

Thanks Robert,

using RA what is the best way to find all the fields associated with a specific template?

0 0
replied on January 4, 2017

Can anyone provide the c# code to add a new value to an existing List using the sdk.

 

Thanks

You are not allowed to follow up in this post.

Sign in to reply to this post.