More in this section

Forums / General Discussions / Retrieve Custom Field from Event Module

Retrieve Custom Field from Event Module

2 posts, 0 answered
  1. Douglas
    Douglas avatar
    7 posts
    16 Dec 2015
    03 Feb 2016
    Link to this post


    I´m using sitefinity 8.2 version in a MVC aplication where I have created two custom fields in Events built-in module.

    When I bring a detailed single event I can see all its properties including the image etc.

    But after I try all possible tutorials to bring the custom fields that I have created it always returns null.

    For example:

    EventsManager eventsManager = EventsManager.GetManager();
    Event item = eventsManager.GetEvents().Where(ev => ev.UrlName == itemName).FirstOrDefault(); // it works and bring the single item

    How can I query the two custom fields created ?


  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    18 Sep 2017
    09 Feb 2016
    Link to this post

    Manually add
    using Telerik.Sitefinity.Model;
    to make available the extension methods GetValue and SetValue extension methods.

    Get the custom fields like this
    EventsManager eventsManager = EventsManager.GetManager();
               Event item = eventsManager.GetEvents().Where(ev => ev.GetValue<decimal>("VisitorsCount") == 12).FirstOrDefault();
               var testFieldvalue = item.GetValue("Testfield");
               item.SetValue("TestField", "new value");

    Stanislav Velikov
    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
2 posts, 0 answered