Error after creating a News item - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Error after creating a News item

  • Error after creating a News item
  • 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.


  • 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.
  • 266557_newsitem.jpg

    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.