Dynamic data and creating new fields

Posted by Community Admin on 04-Aug-2018 10:20

Dynamic data and creating new fields

All Replies

Posted by Community Admin on 02-Apr-2012 00:00

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?

thanks

Posted by Community Admin on 05-Apr-2012 00:00

Hi,

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));
metaManager.SaveChanges();


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

This thread is closed