More in this section

Forums / Developing with Sitefinity / Dynamic data and creating new fields

Dynamic data and creating new fields

2 posts, 0 answered
  1. Nick
    Nick avatar
    113 posts
    21 Oct 2008
    02 Apr 2012
    Link to this post
    I've used the following code to create two new custom fields for images:

    App.WorkWith().DynamicData().Type(typeof(Image)).Field().TryCreateNew(CaptionFieldName, typeof(string)).SaveChanges(true);
                App.WorkWith().DynamicData().Type(typeof(Image)).Field().TryCreateNew(DestinationUrlFieldName, typeof(string)).SaveChanges(true);
    When run both of these fields get created, but instead of being strings (I want them as short text) they get created as "unknown" types and are therefore not available when managing images. What do I need to do different to ensure these fields for created properly?


  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    18 Sep 2017
    05 Apr 2012
    Link to this post

    Make sure you call prior to executing the assigning of the custom fields.
    var metaManager = Telerik.Sitefinity.Data.Metadata.MetadataManager.GetManager();
    var type = metaManager.CreateMetaType(typeof(Image));

    All the best,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered