Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

MetaFieldBuilder class

Create meta-fields based on existing system meta-types.

The MetaFieldBuilder class has the following methods:

  • CreateGuid
  • CreateDateTime
  • CreateDate
  • CreateInteger
  • CreateFloat
  • CreateCurrency
  • CreateCheckBoxBoolean
  • CreateDropDownBoolean
  • CreateText
  • CreateEmail
  • CreateUrl
  • CreateLongText
  • CreateHtml
  • CreateFile
  • CreateImage
  • CreateReference
  • CreateReferencedField
  • CreateBackReference
  • CreateCardField
  • CreateEnumField
  • CreateAggregation
  • CreateIntegerPercent
  • CreateFloatPercent
  • CreateDecimalPercent
  • CreateDecimal
  • CreateDuration

When you use the MetaFieldBuilder, the Edit scope is automatically opened.

Create a meta-field with MetaFieldBuilder

Example: Using MetaFieldBuilder to create a meta-field.

using (MetaFieldBuilder builder = new MetaFieldBuilder(metaClass))
      {
        builder.CreateDateTime(CreatedFieldName, CreatedFriendlyName, false, true);
        builder.CreateText(CreatorFieldNameText, CreatorFriendlyName, false, 50, false);
        builder.CreateGuid(CreatorFieldNameGuid, CreatorFriendlyName, false);
        builder.CreateInteger(CreatorFieldNameInteger, CreatorFriendlyName, false, -1);
        builder.SaveChanges();
      }