Try our conversational search powered by Generative AI!

Programatically add MetaField to Edit/View Form


I am currently creating my MetaFields for both MetaDataPlus and BusinessFoundation programatically.

When using MDP everything works as expected and the added fiels show up om the MDP-class when viewing i.e lineitems.

But when adding metafields to a BusinessFoundation object it only gets added to the specified class and I manually have to add the fields to the Form-views (Edit Form, View Form).

Does anyone have any suggestions on how to programatically add metafields to the forms for a specific metaclass?

May 12, 2015 15:34

Same issue as I'm having in this post: Make custom meta fields display in Commerce Manager contact management

Does anybody have an answer for this?

Edited, May 15, 2015 9:17

I'm guessing there is no solution to this besides handling this manually..

May 26, 2015 9:42

That's my conclusion as well, but it would be nice with a confirmation from EPiServer. This seems like a fairly straight forward thing to accomplish, so I don't understand why it isn't possible.

May 26, 2015 9:49

After adding the metafields to the metaclass you can add the field to the desired form by code as well.

The function to use is:
FormController.AddMetaPrimitive(string metaClassName, string formName, string fieldName)

The Form names are:

Edit Form -> [MC_BaseForm]
Short Info Form -> [MC_ShortViewForm]
View Form -> [MC_GeneralViewForm]

Feb 19, 2016 16:40

Thank you Mark!

Mar 03, 2016 14:47
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.