Skip to main content
2 of 3
added 43 characters in body
Ant P
  • 2k
  • 16
  • 27

How to access the nested Embedded Schema fieldsin C# Fragement

I have three Schema A (Content) , B(Embedded), C(Embedded)

Schema A have fields A1(text) and A2(EmbeddedSchema)

Schema B have fields B1(EmbeddedSchema), B2(text) And Schema C have fields C1(text) and C2(text)

Schema B is embedded with field A2 and Schema C is embedded with field B1.

How to get the value of C1 field in C# TBB/Fragment.

I am doing to get the value of field A2 (document_order) with below code but unable to get the in field C1

if (pubMetadata.Contains("order_sort"))
{    
    foreach (ItemFields docsort in ((EmbeddedSchemaField)pubMetadata["order_sort"]).Values) 
    {
        //Below code line works 
        string docOrder = ((KeywordField)docsort["document_order"])
                              .Value.Description.ToString();

        //Below code line is not working 
        string docSortName = ((KeywordField)docsort["doc_sort"])
                                 .Value.Description.ToString();                   
    }

}
user584
  • 1.1k
  • 5
  • 10