More in this section
Forums / Sitefinity SDK / Error after creating a News item

Error after creating a News item

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.
3 posts, 0 answered
  1. Lupi
    Lupi avatar
    38 posts
    17 May 2004
    20 Aug 2010
    Link to this post
    Hello again,

    I have a problem when creating a news item from code. Following this example:

    I have this code

    var newsManager = NewsManager.GetManager();
    newsManager.Provider.SuppressSecurityChecks = true;
    var news = newsManager.CreateNewsItem();
    news.Author = "John Smith";
    news.Content = "This is some sample content.";
    news.Summary = "Sumary";
    news.Title = "News Item";
    news.SourceName = "None";
    news.DateCreated = DateTime.Now;
    news.PublicationDate = DateTime.Now;
    news.ExpirationDate = DateTime.Now.AddMonths(1);

    It executes ok, then I can see the new item in Contents->News in the administration. But then I click on the item to edit it and I get this error (error1.png). You see there is no title, nor contents here. Then I click "Back to all items" and I get second error (error2.png) and I can no longer see the item in the list. I have to go and delete manually database records in order to clear the news list.

    I suppose it might have something to do with security and permissions, but there are no examples on how to use it.

  2. Lupi
    Lupi avatar
    38 posts
    17 May 2004
    20 Aug 2010
    Link to this post
    Never mind. I had to set the Owner property of the NewsItem.

    Also, on a side note, when creating a PageTemplate, remember to set its Category like this -

    template.Category = SiteInitializer.CustomTemplatesCategoryId;

    or you get a nasty exception.
  3. Andrei
    Andrei avatar
    553 posts
    27 Nov 2008
    27 Apr 2011
    Link to this post

    After the upgrade to 4.1 my news module does not work very well any more (see attached image).

    I changed the label of the 'SourceName' field and it gets Invalid resource.

    Also, I need to hide the whole URL field but from the Templates it can not be done.

3 posts, 0 answered