Error after creating a News item
Hello again,
I have a problem when creating a news item from code. Following this example:
http://www.sitefinity.com/40/help/developer-manual/modules-built-in-modules-api-news-creating-news-content.html
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);
newsManager.RecompileItemUrls<NewsItem>(news);
newsManager.Publish(news);
newsManager.SaveChanges();
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.
Regards,
Lupi
Never mind. I had to set the Owner property of the NewsItem.
Hi,
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.
Thanks,
Andrei