While creating some JSON for the Metadata on a Structure Group in C# I came across an interesting challenge to display the URI and Title of the Embedded Schema. Initially I was using a FieldDefinition instead of an EmbeddedFieldDefinition and then the ID and Title properties were not available of the Embedded Field. Casting the variable to an EmbeddedSchemaFieldDefinition was the proper way to access the EmbeddedField definition info.
EmbeddedSchemaField right1Field = pageMetaFields[fieldName] as EmbeddedSchemaField; EmbeddedSchemaFieldDefinition def = right1Field.Definition as EmbeddedSchemaFieldDefinition; embeddedSchemaFieldDef.RootElementName = def.EmbeddedSchema.RootElementName; //"Content"; embeddedSchemaFieldDef.Id = def.EmbeddedSchema.Id; // "tcm:11-123-8"; embeddedSchemaFieldDef.Title = def.EmbeddedSchema.Title; // "Metadata fieldname";
Leave a Reply