Modify News Publication Date

Posted by Community Admin on 04-Aug-2018 09:12

Modify News Publication Date

All Replies

Posted by Community Admin on 16-Sep-2011 00:00
Hi!

Can you please tell me how can I modify the publication date of the news items?
I allowed the PublishDate to visible from custom field options and it is displaying on the edit mode of news but when I update the publish date it does not update.
I am using sitefinity 4.1 SP3.

Can you please reply ASAP.

Thanks!
Posted by Community Admin on 16-Sep-2011 00:00
Hello Waqar,

You can modify the publication date of the news items programmatically. Please consider the bellow sample:

var newsAll = App.WorkWith()
                .NewsItems()
               // .Where(nI => nI.Status == ContentLifecycleStatus.Live)
                .ForEach(nI =>
                
                    var val = nI.GetValue("NewsDate").ToString();
                    var ss = DateTime.Parse(val);
                    nI.PublicationDate = ss;
                    nI.DateCreated = ss;
                )
                   
                .SaveAndContinue();

Please take into consideration the NewsDate value which is a custom field added to your News items, and contains the desired date.

Greetings,
Victor Velev
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
Posted by Community Admin on 27-Sep-2011 00:00
HI !

Thanks for the reply,

I run this code but foreach loop I am getting following error
" An item with the URL '/2011/09/09/-بنك-دبي-الإسلامي-و-الأردن-دبي-كابيتال-و-دبي-انترناشونال-' already exists."

Can you please help me on this? I have more than 200 news I can't repopulate them.

Please come up with some solution.
Posted by Community Admin on 30-Sep-2011 00:00
Hi Waqar,

The sample code that I have provided you with is a solution on how to achieve the desired results using the API, if you do not intend on having a custom field from the backdating process, then you can simply pass a valid date to the code and set the PublicationDate/DateCreated accordingly.

You also have the option to upgrade to our 4.2 SP1 release, which contains this functionality built - in the system.

Kind regards,
Victor Velev
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
This thread is closed