I’m trying to set the value of a Contentment Data List programmatically but it’s not showing up in either the published content or in the back office (i.e. the property editor just has the ‘Add’ button).
I’ve taken a look at how the data is stored in the database and matched that in my code, which is:
// Save it as a - ["umb://document/384a88735d8141758d998beaebb82420"]
var itemUdi = Udi.Create("document", myTargetContent.Key);
var data = JsonConvert.SerializeObject(new string[] { itemUdi });
content.SetValue("myAlias", data);
I’ve compared my programmatically saved value with that from a normal back office save and they are identical - does anyone have an idea what I might be missing please?
Thanks Lee. Yup, it’s part of a large migration script and the other properties were coming through OK.
I got this working in the end by saving it as a self-made string. But then after a PC restart I took another look and the original serialisation code worked just fine.
// Manually make the string representation of the array
var itemUdi = Udi.Create("document", myTargetContent.Key);
var data = "[\"" + itemUdi + "\"]";
content.SetValue("myAlias", data);