Add custom field to List - Programmatically

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

Add custom field to List - Programmatically

All Replies

Posted by Community Admin on 24-Jan-2013 00:00

Hi,
i created a list with this block of code:
         App.WorkWith().List().CreateNew(listID)
                .Do(l =>
               
                    // Set the list properties
                    l.Title = listTitle;
                    l.Description = listDescription;
                    l.UrlName = Regex.Replace(supplierListTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
                    l.DateCreated = DateTime.Now;
                )
                .SaveChanges();

How can i add two custom fields to the list?
1º Email (string)
2º Contacts (string)

Another question:
Why custom fields are common to all lists? is unnatural that kind of option, no?

Thanks for the help

Posted by Community Admin on 24-Jan-2013 00:00

Hello Nuno,

Please refer to this documentation on creating custom fields using the API.
Adding custom fields for only one list is not possible. When a custom field is added it applies to all lists. The same rule applies for all content modules in Sitefinity because custom fields are tied to a object type rather than a single row of data. Consider a scenario how each row (in the same table) would have different columns, which is not possible by database rules so custom fields per row (or list in this case) is not possible as well.

All the best,
Venkata Koppaka
the Telerik team

Posted by Community Admin on 25-Jan-2013 00:00

Thanks.


Posted by Community Admin on 11-Jul-2014 00:00

Hi Venkata,

If I have created some custom fields in List Itmes then can I access them using fluent API?

Regards,

Harshil Shukla

Posted by Community Admin on 14-Jul-2014 00:00

Hello Harshil,

The following article shows how you can access custom fields: Getting the value of a custom field

Regards,
Nadezhda Petrova
Telerik

 
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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed