I have added a new property - a Umbraco.DropDown.Flexible to a doctype thats used for nested content. The site has hundreds of instances of this nested content so i need to create a routine that sets the new property based one of the other properties (the title textstring). I loop through the published content of these instances, then create a new object and save the nested content property using contentservice. However while i am able to save textstrings, i cannot save complex datatypes. One of the properties is a Umbraco.MultiUrlPicker, and i cannot manage to pass that back in to the object to be saved.
In the code below "columnType" is the new property, and "itemLink" is the Url Picker
var nestedContentValue = new JArray();
if (results != null && results.Any()) {
foreach (var b in results) {
var nestedContentItem = new JObject();
nestedContentItem.Add("key", Guid.NewGuid().ToString());
nestedContentItem.Add("ncContentTypeAlias", "resultItem");
nestedContentItem.Add("itemTitle", b.GetPropertyValue<string>("itemTitle"));
nestedContentItem.Add("columnType", "1335");
nestedContentItem.Add("itemFilesizeText", b.GetPropertyValue<string>("itemFilesizeText"));
nestedContentItem.Add("itemLink", JsonConvert.SerializeObject(b.GetProperty("itemLink")));
nestedContentValue.Add(nestedContentItem);
}
var contentItem = cs.GetById(testnodeid);
contentItem.SetValue("items", JsonConvert.SerializeObject(nestedContentValue));
var saveresult = cs.SaveAndPublishWithStatus(contentItem);
}
I have also tried the following approach, but this gave the same outcome: "itemLink" is not set
Problem updating Nested Content programmatically
I have added a new property - a Umbraco.DropDown.Flexible to a doctype thats used for nested content. The site has hundreds of instances of this nested content so i need to create a routine that sets the new property based one of the other properties (the title textstring). I loop through the published content of these instances, then create a new object and save the nested content property using contentservice. However while i am able to save textstrings, i cannot save complex datatypes. One of the properties is a Umbraco.MultiUrlPicker, and i cannot manage to pass that back in to the object to be saved.
In the code below "columnType" is the new property, and "itemLink" is the Url Picker
I have also tried the following approach, but this gave the same outcome: "itemLink" is not set
Can anyone tell me the correct way to set these troublesome properties?
So i finally worked it out. I had to add the property in its json form:
is working on a reply...