Getting a list of Kentico contact fields

Mike Rocha asked on September 8, 2014 21:34

I'm looking to develop a module for mapping data from an external database to Kentico on-line marketing contacts. Is there an easy way to list the field names and captions for all standard and custom fields from the built-in OM.Contact class?

Recent Answers

Jakub Oravec answered on September 18, 2014 17:10

Hi Mike,

Have a look at CMS.FormEngine.FormHelper.GetFormInfo method. It takes one or more class names and returns FormInfo object representing form definition. You can use GetFields method of the FormInfo object to get more details on individual fields including field name, type, default value, etc.

FormInfo fi = FormHelper.GetFormInfo("OM.Contact", false);
var fields = fi.GetFields(true, true);
foreach (FormFieldInfo field in fields)
  // Do stuff with field.Caption or field.Name
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.