More in this section
Forums / Developing with Sitefinity / Add custom field to List - Programmatically

Add custom field to List - Programmatically

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
5 posts, 0 answered
  1. Nuno
    Nuno avatar
    9 posts
    04 Jan 2013
    24 Jan 2013
    Link to this post
    i created a list with this block of code:
                    .Do(l =>
                        // Set the list properties
                        l.Title = listTitle;
                        l.Description = listDescription;
                        l.UrlName = Regex.Replace(supplierListTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
                        l.DateCreated = DateTime.Now;

    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
  2. Venkata Koppaka
    Venkata Koppaka avatar
    67 posts
    24 Sep 2012
    24 Jan 2013
    Link to this post
    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
  3. Nuno
    Nuno avatar
    9 posts
    04 Jan 2013
    25 Jan 2013
    Link to this post


  4. Harshil
    Harshil avatar
    5 posts
    19 Mar 2014
    11 Jul 2014
    Link to this post

    Hi Venkata,

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


    Harshil Shukla

  5. Nadezhda Petrova
    Nadezhda Petrova avatar
    20 posts
    09 Jan 2017
    14 Jul 2014
    Link to this post
    Hello Harshil,

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

    Nadezhda Petrova
    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
5 posts, 0 answered