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

Question

Question

Setting Dynamic Field Option in an Integration

asked on May 20, 2014

I have an integration that allows the user to assign template data to a document before it is imported into Laserfiche in a UI outside of Laserfiche.   Does the SDK have functionality to interact with Dynamic fields?  Is there a way to retrieve the values that should be available in the child field based on the value the user selects in the parent field?

 

Thanks,

 

Russell

1 0

Replies

replied on May 20, 2014

In RepositoryAccess, the logic associated with dynamic fields is accessible through the FormLogicRuleInfo class. If you want to get pre-existing logic rules, the TemplateInfo object has a GetFormLogicRules method that returns an array of FormLogicRuleInfos, and a HasFormLogicRules method that returns a boolean indicating whether there are logic rules associated with the Template. If you want to interact with the external tables that the dynamic fields use, you can use the LfExternalTableInfo class. To retrieve the values that should be available in a field with dynamic rules, you will need to use the GetDataReader method on the relevant FormLogicRuleInfo, and read the appropriate data out of the returned LfDataReader. All of this is rather complex, so you will want to consult your SDK documentation and do some experimentation to get a feel for how it all works.

1 0
replied on May 21, 2014

Any chance I can get some sample code using both the FormLogicRuleInfo class and the LfExternalTableInfo class?

0 0
replied on October 3, 2019 Show version history

Hi Russell , 

Please check this code.


        public static List<string> getFieldDynamicValues(String templateName, String fieldName)
        {
            List<string> dynamicValues = new List<string>();

            TemplateInfo myLFTemp = Template.GetInfo(templateName, LFConnectionSingleTon.LFSession);

            if (myLFTemp.HasFormLogicRules())
            {
                FormLogicRuleInfo[] FormLogicRules = myLFTemp.GetFormLogicRules();

                foreach (FormLogicRuleInfo dynamicField in FormLogicRules)
                {
                    FieldInfo tfield = Field.GetInfo(dynamicField.FieldId, LFConnectionSingleTon.LFSession);
                    if (tfield.Name == fieldName)
                    {
                        FieldValueCollection coll = new FieldValueCollection();
                        coll.Add(fieldName, "");
                        using (LfDataReader reader = dynamicField.GetDataReader(coll))
                        {
                            if (reader.HasRows)
                                while (reader.Read())
                                {
                                    dynamicValues.Add(reader[0].ToString());
                                }
                        }
                    }
                }

            }

            return dynamicValues;
        }

 

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

Sign in to reply to this post.