Hi, I’m trying to update the text data in a FiledType.TextOption field but I can’t seem to find the correct method. All Collections and option seem to be readOnly. The following test code is from inside a Products.Events.FieldDefinitionUpdated event. I can read all the values, but can’t find any documentation on how to set, update or replace the values. Creating a new field works fine using ‘fieldDefinitionService.Create()’
var currentField = fieldDefinitionService.Get("Brand");
if (currentField != null )
{
//Cast the filed option
TextOption brandList = (TextOption)updateEvent.Item.Option;
//try to update field
for (var i = 0; i < brandList.Items.Count; i++)
{
//First try
brandList.Items[i].Value = + "_"; //Fails Object read only
//Second try fails Read only collection
brandList.Items.Insert(i, new TextOption.Item
{
Value = brandList.Items[i].Value + "_",
Name = brandList.Items[i].Name
} );
}
updateEvent.Item.Option = brandLis; //Fails
fieldDefinitionService.Update(updateEvent.Item); //This have no effect?
}
Litium version: 6.2