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

Question

Question

LF SDK Repository Access - Reorganize Fields in Field Value Collection(FVC)

asked on March 2, 2017

Hello All,

In the app I am creating using LF data, I can get all the fields in a template as a collection using RA.  However, I assumed that the fields would be listed in the same order as I would see them when I launch the LF Client Document Viewer.  When using the SDK the fields in the FVC are in alphabetical order.  Does anyone know what I can use to get the same ordering of fields in the LF Client using the SDK?  I have looked at the documentation and have yet to resolve.  I am hoping that there is an option to get the right ordering in the FVC instead of handling using code after storing in an object.

 

Thanks in advance.

0 0

Answer

SELECTED ANSWER
replied on March 2, 2017

Get the order from the document's template:

EntryInfo entry = Entry.GetEntryInfo(id, session);

FieldValueCollection fvc = entry.GetFieldValues();

List<string> templateFields = new List<string>();

// Print the fields in the template
if (!string.IsNullOrEmpty(entry.TemplateName))
{
    TemplateInfo entryTemplate = Template.GetInfo(entry.TemplateName, session);

    foreach (FieldInfo field in entryTemplate.Fields)
    {
        Console.WriteLine(String.Format("{0}: {1}", field.Name, fvc[field.Name]));
        templateFields.Add(field.Name);
    }
}

// Print the independent fields (the ones not in the template)
foreach (KeyValuePair<string, object> fieldVal in fvc)
{
    if (!templateFields.Contains(fieldVal.Key))
        Console.WriteLine(String.Format("{0}: {1}", fieldVal.Key, fvc[fieldVal.Key]));
}

 

1 0
replied on March 2, 2017

Thanks Robert, I can now get these into my dictionary in the correct order to display the fields and values in my app!

 

I very much appreciate the help!  Thanks again!

 

0 0

Replies

You are not allowed to reply in this post.
replied on March 2, 2017

As you've found, the FieldValueCollection just stores the data as key/value pairs.  The ordering comes from the template that's assigned to the entry.  For fields that are not part of the template ("independent fields"), the convention is to display them in alphabetical order after the ones that belong to the template.

You are not allowed to follow up in this post.

Sign in to reply to this post.