More in this section

Forums / Bugs & Issues / Modify News Publication Date

Modify News Publication Date

4 posts, 0 answered
  1. waqar
    waqar avatar
    76 posts
    Registered:
    28 Mar 2011
    16 Sep 2011
    Link to this post
    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!
  2. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    16 Sep 2011
    Link to this post
    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
  3. waqar
    waqar avatar
    76 posts
    Registered:
    28 Mar 2011
    27 Sep 2011
    Link to this post
    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.
  4. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    30 Sep 2011
    Link to this post
    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
4 posts, 0 answered