1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Accessing Custom Fields

Accessing Custom Fields

18 posts, 0 answered
  1. Alex
    Alex avatar
    39 posts
    Registered:
    19 Jul 2010
    20 Jan 2011
    Link to this post
    I have added custom fields to the news content, but when I am not able to access those properties through the NewsManager.  Is there a different process to access the custom fields?

    Thanks,
    Alex Lorenz
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    20 Jan 2011
    Link to this post
    Hi Alex,

    There are methods SetValue and GetValue of Telerik.Sitefinity.Model.DataExtensions that you can use to get/set metafields

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Alex
    Alex avatar
    39 posts
    Registered:
    19 Jul 2010
    20 Jan 2011
    Link to this post
    When I loop through the news items do I call the GetValue method then or do I have to do it a different way.  Here is how my code looks:
    NewsManager manager = NewsManager.GetManager();
    IQueryable<NewsItem> newsItems = manager.GetNewsItems()
                      .Where(t => t.Status == ContentLifecycleStatus.Live)
                      .OrderByDescending(o => o.PublicationDate);
     
    int i = 0;
     
    foreach (NewsItem item in newsItems)
    {
        i++;
                        
        this.items.InnerHtml += "<div id=\"" + item.Id + "\">" + item.Title + "</div>" + Environment.NewLine;
     
        if (i > 5)
        {
            break;
        }
    }
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Jan 2011
    Link to this post
    Hello Alex,

    Here is a sample code that you can use

    var newsItems = App.WorkWith().NewsItems()
    .Where(t => t.Status ==Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
    .OrderByDescending(o => o.PublicationDate)
    .Get()
    .ToList();
     
                foreach (var item in newsItems)
                {
                    var summary = item.GetValue("Summary");
                }


    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Alex
    Alex avatar
    39 posts
    Registered:
    19 Jul 2010
    21 Jan 2011
    Link to this post
    I'm getting the following error on the GetValue method: 

    'Telerik.Sitefinity.News.Model.NewsItem' does not contain a definition for 'GetValue' and no extension method 'GetValue' accepting a first argument of type 'Telerik.Sitefinity.News.Model.NewsItem' could be found (are you missing a using directive or an assembly reference?)

    I have tried adding a reference to Telerik.Sitefinity.Model.DataExtensions, but it says it does not exist.  What am I missing?


  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Jan 2011
    Link to this post
    Hi Alex,

    Here is the API reference that shows the namespace and method signature.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Alex
    Alex avatar
    39 posts
    Registered:
    19 Jul 2010
    21 Jan 2011
    Link to this post
    All the code seems to look correct now, but when I go to utilize the value it is blank even though it is not null.  Am I not utilizing the var correctly?

    var HeadlineImage = item.GetValue("HeadlineImage");
                     
    if (HeadlineImage.ToString().IsNullOrEmpty())
    {
           this.items.InnerHtml += "<img src=\"" + HeadlineImage.ToString() + "\" />" + Environment.NewLine;
    }
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Jan 2011
    Link to this post
    Hi Alex,

    Most probably there is no value set for HeadlineImage for the item you use. Please make sure that you have set value for this item by using SetValue and you have called SaveChanged().

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Alex
    Alex avatar
    39 posts
    Registered:
    19 Jul 2010
    21 Jan 2011
    Link to this post
    There were values set, but I was missing an if statement.  However, I noticed that if I update one news item that was initially 3rd when returned, it is now 1st.  Is there an "original" publish date so that if changes get made to an already published news item that it won't move up in order?

    Thanks for all your help!
  10. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    26 Jan 2011
    Link to this post
    Hello Alex,

    There are sorting settings for news list. Can you please check what are your sorting settings in the news view control?

    Kind regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Alex
    Alex avatar
    39 posts
    Registered:
    19 Jul 2010
    26 Jan 2011
    Link to this post
    I am sorting by the newest first.
    Thanks,
    Alex Lorenz
  12. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    06 Jul 2011
    Link to this post
    Hi,

    I have the latest build 4.1.1501.0 and on my development machine with IE8, I can access the Custom Fields for news, but when I publish the application and take it on the test system with IE9, I cannot access the Custom Fields for news. It says that the default fields cannot be edited or hidden. also, it says that no custom fields have been added when I have one on the page added from a long time ago. The same version on my development PC shows everything as it always did but on the test machine it does not. Also, on the test machine it switched all the labels to the defaults. What happens between me publishing it on the development machine and running it on the test machine that all the resources switch to their defaults. Could the different version of IE do all that?
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    07 Jul 2011
    Link to this post
    Hello Andrei,

    This should not be a browse issue. It looks like the configuration files form App_Data are not moved or you are not using the correct database.

    Best wishes,
    Ivan Dimitrov
    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
  14. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    11 Jul 2011
    Link to this post
    Ivan,

    I am deleting all the files and completely replace them with the newly published. Also, I back-up the database as well on which I am working upstairs and restore it downstairs. Not too sure what's going on.

    Thanks,
    Andrei
  15. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    11 Jul 2011
    Link to this post
    Hi Andrei,

    Does the issue still persist? I cannot get whether you resolve it or not.

    Kind regards,
    Ivan Dimitrov
    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
  16. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    11 Jul 2011
    Link to this post
    Ivan,

    It happens when I switch from my development PC to the test PC. But when I change the resource labels then it is ok. Not sure why that happens. It does not remember them accross, but remembers everything else.

    Thanks,
    Andrei
  17. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 Jul 2011
    Link to this post
    Hi Andrei,

    From the description you are providing it looks like that not all data is moved between both the machines. You are missing some config file or some database entry ( if you use database replication tool).

    Best wishes,
    Ivan Dimitrov
    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
  18. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    12 Jul 2011
    Link to this post
    Ok Ivan.
    Thanks. I will investigate.
    Andrei
18 posts, 0 answered