Proper way to set value of a property of type Nested Content programmatically
I have a nested content property that i am trying to modify programmatically. Following is my code:
var nestedStr = linkedContent.GetValue<string>("linkedElements");
var nestedResult = nestedStr == null ? new List<RootObject>() : JsonConvert.DeserializeObject<List<RootObject>>(nestedStr);
var obj = new RootObject()
{
name = node.Name,
ncContentTypeAlias = link.ncContentTypeAlias,
relationType = type,
linkedElement = JsonConvert.SerializeObject(lst),
statement = link.GetPropertyValue<string>("statement")
};
nestedResult.Add(obj);
nestedStr = JsonConvert.SerializeObject(nestedResult);
if (isNew)
{
linkedContent.SetValue("linkedElements", nestedStr);
sender.SaveAndPublishWithStatus(linkedContent);
}
This is all working fine but when i save the linkedContent it's not reflecting on the website. I have to go to the backend and "Save and Publish" it manually then everything works fine.
Maybe it's because i am creating my own objects and in process missing a lot of inherited properties while updating the nested content property. Please can someone point me to the right direction?
Proper way to set value of a property of type Nested Content programmatically
I have a nested content property that i am trying to modify programmatically. Following is my code:
This is all working fine but when i save the
linkedContent
it's not reflecting on the website. I have to go to the backend and "Save and Publish" it manually then everything works fine.Maybe it's because i am creating my own objects and in process missing a lot of inherited properties while updating the nested content property. Please can someone point me to the right direction?
is working on a reply...