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

Question

Question

read template filed

SDK
asked on November 19, 2016

Hi every one,

i'm very new to LF SDK. 

i would like to create a small application that can read a template filed value from my selected document in the client. 

can you please point me to an article/example code that can allow me to do so.

thank you in advance 

 

0 0

Replies

replied on November 21, 2016

Here is how to use CAT to get the fields for all selected entries:

using Laserfiche.RepositoryAccess;
using Laserfiche.ClientAutomation;

.....

using (ClientManager clientmgr = new ClientManager())
{
    foreach (ClientWindow window in clientmgr.GetAllClientWindows(ClientWindowType.Main))
    {
        MainWindow mainWindow = (MainWindow)window;
        try
        {
            List<int> selectedEntries = (List<int>)mainWindow.GetSelectedEntries();
            foreach (int entryId in selectedEntries)
            {
                RepositoryConnection conn = mainWindow.GetCurrentRepository();
                string serializedConnection = conn.GetConnectionString();
                using (Session session = Session.CreateFromSerializedLFConnectionString(serializedConnection))
                {
                    EntryInfo entryInfo = Entry.GetEntryInfo(entryId, session);
                    FieldValueCollection fvc = entryInfo.GetFieldValues();
                    foreach (string fieldName in fvc.FieldNames)
                    {
                        object objFieldValue = fvc[fieldName];
                        string fieldValue = "";
                        if (objFieldValue is object[])
                        {
                            // Multivalue field
                            foreach (object subValue in (object[])objFieldValue)
                            {
                                if (!String.IsNullOrEmpty(fieldValue))
                                    fieldValue += ", ";
                                fieldValue += subValue.ToString();
                            }
                        }
                        else if (objFieldValue != null)
                            fieldValue = objFieldValue.ToString();

                        Console.WriteLine(String.Format("{0}: {1}", fieldName, fieldValue));
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
}

 

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

Sign in to reply to this post.