Structure Attributes - How can i get them?

Structure Attributes - How can i get them?

  
Good morning!

Is there anyway to get the names from structure attributes?! We can do it with entity attributes with the System entities "entity" and "entity_attrb". How can i do the same thing but with structures?

Thanks.
Best regards,
Diogo Pacheco
Diogo Pacheco wrote:
Good morning!

Is there anyway to get the names from structure attributes?! We can do it with entity attributes with the System entities "entity" and "entity_attrb". How can i do the same thing but with structures?

Thanks.
Best regards,
Diogo Pacheco
 
Hi Diogo.
You can do that by building an extension that receives an instance of the said structure (record or recordlist) as Object, then use Reflection on it to get the attribute names.

Eg. (Working for record object)
        private string structurePrefix = "ssST";
        private string fieldPrefix = "ss";
public void MssStructureFields(object ssStructure, out RLFieldRecordList ssParameter1) {
ssParameter1 = new RLFieldRecordList(null);
            RCFieldRecord field = new RCFieldRecord();
            FieldInfo[] _fieldInfo = ssStructure.GetType().GetFields();
 
            foreach (FieldInfo _fi in _fieldInfo)
            {
                {
                    if (_fi.Name.IndexOf(structurePrefix) == 0)
                    {
                        foreach (FieldInfo fi in _fi.GetValue(ssStructure).GetType().GetFields())
                        {
                            if (fi.Name.IndexOf(fieldPrefix) == 0)
                            {
                                field.ssSTField.ssName = fi.Name.Replace(fieldPrefix, "");
                                ssParameter1.Append(field);
                            }
 
                        }
                    }
                }
            }
}

Edit: The same logic can be implemented to retrieve Entity attribute names, probably changing the prefix constants, so you can avoid querying the database to retrieve that info, thus improving performance. :)
Related to this... does anyone know of a way to obtain the attribute Description/Label? Is it not avaliable in the Entity/Structure Instance? (Makes sense btw)
António Chinita wrote:
Related to this... does anyone know of a way to obtain the attribute Description/Label? Is it not avaliable in the Entity/Structure Instance? (Makes sense btw)
 
 As far as I know you can't get it via reflection. You would have to query the system data model for that info.


Miguel
That's right, you need to query the system data model for it or use the Documentation API (the extension that is bundled with OutDoc) to view that information. This API is, by the way, the only way to get that information for structures...
Just open up OutDoc and check how it uses the API. 
cheers
and what about the descriptions of these attributes? Is it possible?
Yes, through the system data model. The attribute description is in the ossys_entity_attr table.

Miguel
I'm not sure you understand. What i am trying to do by c# is to get the description of the structure's field that i have in a recordlist