Nested content introduced a new interface IPublishedElement. How do we create and save nested content in Umbraco 8 through a controller? It appears that Serializing a List<Dictionary<string, object>> to json doesn't work.
As stated in the last comment in the thread, you have to make sure that the property is not empty, otherwise you cannot save anything to it - it simply does not exist yet.
My workaround was to save an empty dummy dictionary item on the property on content creation or if the property is null, to make the property "exist". Then, when saving the real nested content dictionary items to the property I remove the first item in the dictionary list (the dummy item) prior to adding the new items.
Not pretty but it works as a temporary solution, until hopefully fixed (maybe on Tuesday with the v8.0.2 update, who knows.)
Saving nested content
Nested content introduced a new interface IPublishedElement. How do we create and save nested content in Umbraco 8 through a controller? It appears that Serializing a
List<Dictionary<string, object>>
to json doesn't work.Please look at Davids answer in this answer for Umbraco 7. I have it working in V8 as well with a little workaround.
https://our.umbraco.com/packages/backoffice-extensions/nested-content/nested-content-feedback/88895-creating-nested-content-programatically
As stated in the last comment in the thread, you have to make sure that the property is not empty, otherwise you cannot save anything to it - it simply does not exist yet.
My workaround was to save an empty dummy dictionary item on the property on content creation or if the property is null, to make the property "exist". Then, when saving the real nested content dictionary items to the property I remove the first item in the dictionary list (the dummy item) prior to adding the new items.
Not pretty but it works as a temporary solution, until hopefully fixed (maybe on Tuesday with the v8.0.2 update, who knows.)
Do you have an example of this please?
I would like to have an example on how you got it to work, if it's possible.
Thanks
Does anyone know if there is a more formal/documented way of doing this yet?
I wrote up a post in Umbraco's github on how to do this. https://github.com/umbraco/Umbraco-CMS/issues/5348
is working on a reply...