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?
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.
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
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.
Scheduled publish event
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?
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.
That's an interesting angle, thank you for that idea!
I'm going to look into it right now...
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...
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.
Hi!
Thanks for sharing!
Keep me posted if you find some other solution :)
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
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.
is working on a reply...