November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi,
The answer of David is for the administration/manual approach. You can also do it programmatically, by those API:s
Mediachase.MetaDataPlus.Configurator.MetaField.Create(...)
Mediachase.MetaDataPlus.Configurator.MetaClass.AddField(MetaField,...)
Regards.
/Q
David, Quan, thank you for the answers. David, yes, I have to do it via API.
Quan, I have an issue related to Mediachase.MetaDataPlus.Configurator.MetaClass.AddField - it always adds row with SystemMetaClassId = 0 to MetaField table. But I need to specify the class (otherwise contraints exception about uniqe (Name, SystemMetaClassId) pair is thrown). But I haven't found any methods to specify SystemMetaClassId on creation. Maybe you can recommend something?
Hi,
You don't have to specify SystemMetaClassId on creation. That should be done automatically. Can you post your code here?
Regards.
/Q
var mc = MetaClass.Load(OrderContext.MetaDataContext, OrderConfiguration.Instance.MetaClasses.ShoppingCartClass.Name);
(...)
var metaField = MetaField.Create(MetaDataContext.Instance, metaFieldCreatingParam.Namespace, metaFieldCreatingParam.Name, metaFieldCreatingParam.FriendlyName, metaFieldCreatingParam.Description, metaFieldCreatingParam.MetaDataType, metaFieldCreatingParam.Length, metaFieldCreatingParam.AllowNulls, metaFieldCreatingParam.MultiLanguageValue, metaFieldCreatingParam.AllowSearch, metaFieldCreatingParam.IsEncrypted);
mc.AddField(metaField);
Should this code set SystemMetaClassId field? Possible field SystemMetaClassId is something obsolete, since MetaClassMetaFieldRelation table exists?..
Yes, it should work. The relations between metaclasses and metafields are stored in MetaClassMetaFieldRelation, and I don't see any problem with your code. What's the error you got?
/Q
There is no problems with the code if I don't have DisplayName in MetaField table yet, but there is problem that I have already metafiled with Name="DisplayName" and SystemMetaClassId = 0, but let's say it doesn't suit my purposes because of length. Can I create another metafield called "DisplayName" with another length? Is it possible?
So could you please clarify conception a little: now all metafields in MetaField table are "globally" defined? I mean that for example if I need assign DisplayName field to some metaclass and this field already exists in MetaField table, should I use this existent field? I am not able to create another one with other parameters (like length, isNullable, etc) that fits the needs of some concrete metaclass, am I right?
So why not just delete the old Display Name then create a new one? Having two meta fields with same name is not recommended.
Regards.
/Q
Guys, could you provide an example of configurations that allow meta fields "MetaField1" for ecommerce Cart object:
cart0["MetaField1"] = 5; //for example
As I understand I have to declare metafield somehow first to use it in application.
Thank you!