Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Keith Boynton 19 posts 61 karma points
    Nov 17, 2020 @ 13:06
    Keith Boynton
    0

    I'm using Umbraco 8 and the scheduled publishing is working great. I'm also hooked into the ContentService.Published event which fires when the content has been published, again, all working great.

    What I'm looking for is an event that fires when the scheduling happens rather than the publishing.

    So if on Thursday I schedule a piece of content to be published on Saturday I'd like to handle an event on Thursday (during scheduling) rather than on Saturday (during publishing).

    I couldn't see any documentation on such an event, nor in intellisense, is anyone aware of such an event or another way to hook into that process and do "something" when a user schedules something for publish?

  • Markus Johansson 1911 posts 5735 karma points MVP c-trib
    Nov 17, 2020 @ 21:20
    Markus Johansson
    0

    Hi!

    Hmm, MediaService.Saved should work? If you look at the saved item and look for some scheduled publish date in the future?

    I guess that this event would fire every time the node is saved but technically it’s “rescheduled” on each save I guess.

  • Keith Boynton 19 posts 61 karma points
    Nov 18, 2020 @ 09:59
    Keith Boynton
    0

    That's an interesting angle, thank you for that idea!

    I'm going to look into it right now...

  • Keith Boynton 19 posts 61 karma points
    Nov 18, 2020 @ 17:28
    Keith Boynton
    1

    So... thank you very much Markus for your steer!

    Here is what I came up with for now, in the ContentService.Saving event I used this...

            var blogArticleEntitiesBeingSaved = e.SavedEntities.Where(x => x.ContentType.Alias.Equals("blogArticle")).ToList();
            foreach (var blogArticleEntity in blogArticleEntitiesBeingSaved)
            {
                // Get the release schedule
                var releaseSchedule = blogArticleEntity.ContentSchedule.GetSchedule(ContentScheduleAction.Release).FirstOrDefault();
    
                // Get the publish date (this will only be set if the article has previously had a release schedule)
                var publishDate = blogArticleEntity.GetValue<DateTime>("publishDate");
    
                // If there is a future release schedule date and the publish date hasn't previously been set
                if (releaseSchedule != null && releaseSchedule.Date > DateTime.Now && publishDate == DateTime.MinValue)
                {
                    // Do something you only want to do the first time it's been scheduled
    
                    // Save the publish date so we know it's already been scheduled
                    blogArticleEntity.SetValue("publishDate", releaseSchedule.Date);
                }
            }
    

    It seems to work well for my needs, the publishDate field feels like a bit of a workaround but all subsequent saves of the item after scheduling would trigger too so I needed a way to only do it once (on the first time it's been scheduled).

    There is a message in the UI "A schedule has been updated" that is shown when the content is first scheduled for publish and isn't shown on subsequent saves so presumably there is something schedule event related that could be hooked into but I couldn't find it.

  • Markus Johansson 1911 posts 5735 karma points MVP c-trib
    Nov 19, 2020 @ 07:44
    Markus Johansson
    0

    Hi!

    Thanks for sharing!

    Keep me posted if you find some other solution :)

  • Ido Kerner 2 posts 22 karma points
    Feb 15, 2021 @ 07:26
    Ido Kerner
    0

    Hello Keith, I am also trying to get the ContentService_Published event when schedule publish but with no success. can you pls tell me the steps required to fire the event on schedule publish? When publishing using the save&publish button all working great. tnx for the help in advance

  • Bishwajit 28 posts 98 karma points
    Oct 12, 2023 @ 05:17
    Bishwajit
    0

    I need help on schedule publish. Its not working on if I am using my application solution but working fine in vanilla solution. How to figure out the difference and how to fix the issue.

    Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft