var contentService = Services.ContentService;
var node = contentService.GetById(item.Id);
var contentsched = new ContentSchedule("*", DateTime.Now.AddDays(3), ContentScheduleAction.Expire);
node.ContentSchedule.Clear(ContentScheduleAction.Expire);
node.ContentSchedule.Add(contentsched);
contentService.SaveAndPublish(node);
Programmatically set unpublish date
I am trying to programmatically set unpublish date in Umbraco 8, but i can't seem to figure out how..
I want to do the same as answered here: https://our.umbraco.com/forum/extending-umbraco-and-using-the-api/91642-programmatically-set-unpublish-date?fbclid=IwAR0LJxj_rsZly2Kq9pTh3iTXe2a5QcLHeVEuN5esoGXQk9fplN1AMWp5bj4
But there is no expireDate in Umbraco 8
Hope someone can help :)
Hi Jepser,
think you have to set a content schedule
the tricky bit is the culture, for which I think "*" would mean all languages (it does in other places in the code base).
you might also need to clear it to ensure you not adding extras.
Thank you Kevin, it worked ! :D
This is my final code:
This is not working for me
I can confirm, it´s working here too.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.