This is how I did it in versions prior to 7.5, have not had to do this in 7.5 so don't know if it still works there.
var groupName = "MyNewCustomerGroup";
foreach (MetaFieldType fieldType in DataContext.Current.MetaModel.RegisteredTypes)
if (fieldType.Name == "ContactGroup")
if (!fieldType.EnumItems.Any(item => string.Compare(item.Name, groupName, true) == 0))
Mediachase.BusinessFoundation.Data.Meta.Management.MetaEnum.AddItem(fieldType, groupName, fieldType.EnumItems.Last().OrderId + 1);
The code Vickor posted is correct and should be working, but I suggest a little change to make it more effective:
var metaFieldType = Mediachase.BusinessFoundation.Data.DataContext.Current.MetaModel.RegisteredTypes["ContactGroup"];
You now can use metaFieldType directly without loop.
Hi, using Commerce is there a way to add to the CustomerGroup Dynamically with code?
I can see where you can set and get a specific customer's CustomerGroup but I cant see how you can add a new CustomerGroup item via code into the CustomerGroup list.