Hi. I am trying to programmatically set an attribute of Channel Localized Metadata. But I cannot manage to get it to work.
I have tried a few different ways. Here is the basic example.
Assuming I have a channel, I do:
ChannelData data = channel.getData();
ChannelLocalizedData localizedData = data.getLocalizedData(locale);
ContentInstance locMetaData = localizedData.getDescriptor();
AttributeData attr = locMetaData.getAttribute("MY_ATTRIBUTE");
String myValue = (String) attr.getValue();
That is all working fine. I can read the attribute from Localized Metadata. But now I want to change the attribute.
I have tried this:
locMetaData.setAttributeValue("MY_ATTRIBUTE","My Value");
locMetaData.commit();
When I do that I get an exception: Error 13 (MOCommitError), Message 026-133-0009: A content item cannot be moved to the root folder.
I also tried like this:
locMetaData.setAttributeValue("MY_ATTRIBUTE","My Value");
channel.commit();
But that does not cause the attribute to be changed.
Does anyone know how to do this?