-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content Service - ContentSchedule.Add not saving schedule #7361
Comments
Might be because you're publishing it, I am not sure but Umbraco might assume you don't need the schedule any more since you've published it now. The point in scheduling a publish is that you have saved changes that you don't want to publish yet. Does this work? var newArticle = cs.CreateAndSave("News Article", 1084, "newsArticle");
cs.SaveAndPublish(newArticle);
newArticle.ContentSchedule.Add(DateTime.Now.AddDays(1), DateTime.Now.AddDays(30));
cs.Save(newArticle); Note: I guess this is just sample code, but I do not see the point in publishing the node if you want to schedule the publish? |
Yes, this was just sample code. I've just retried it with your code amendment - same behaviour, the schedule gets dropped completely. Having tested this a bit more, it looks like an issue with the CreateAndSave method. If I use Create method instead like this:
Or
Then the content schedule is respected when I Save and Publish (content remains saved if publish date is in the future), or Save only. The CreateAndSave method seems to be ignoring the Content Schedule completely. |
It looks like the change tracking on I think the problem comes from here when the Content is cloned: clonedContent._schedule.CollectionChanged -= ScheduleCollectionChanged; //clear this event handler if any
clonedContent._schedule = (ContentScheduleCollection)_schedule.DeepClone(); //manually deep clone
clonedContent._schedule.CollectionChanged += clonedContent.ScheduleCollectionChanged; //re-assign correct event handler This appears to remove the event handler from the original |
Hi @HefinJ, We're writing to let you know that we've added the For more information about issues and states, have a look at this blog post Thanks muchly, from your friendly PR team bot :-) |
Hi there, I've started working on this issue. I'm Nurhak and I'm taking some time to triage some issues on the Umbraco CMS issue tracker as part of my Hacktoberfest contribution. I will assess the issue reported, maybe ask some questions if I need more information and ultimately decide whether the issue should be progressed. If so, I'll label and if it has been fixed in a later release or is no longer relevant, I'll close, leaving a friendly message explaining why. Best, Hacktoberfest Contributor |
Hey folks, The fix that @NurhakKaya provided works as expected so I'm going to go ahead and close. Lovely work, Nurhak. Thanks! Emma |
When creating content via the content service and setting a release and expire date - the content schedule does not save when reviewing the created content within Umbraco - content schedule is also empty when using contentService.GetById(1111).
Umbraco version
I am seeing this issue on Umbraco version: 8.4.0
Reproduction
Steps to reproduce
Create two document types Home and News Item, add a custom controller to the Home document type so that it creates a new news item each time the home page is loaded:
Load the home page so that the contoller code is executed.
Expected result
New article to be created, with title of "News Article" and with Publish date of Tomorrows date and an unpublish date in 30 days time.
Actual result
Content was created as expected, but Publish schedule is empty when looking at the News Article in Umbraco.
The text was updated successfully, but these errors were encountered: