I am running the following piece of code on the ContentService_Publishing event which works fine when I click Publish from the CMS however it fails when it is called via an automated publish from a publish At date/time being set on a node as the UmbracoContext is returned as null.
Any ideas of why and a way around it?
void ContentService_Publishing(IPublishingStrategy sender, PublishEventArgs<IContent> e) { foreach(var node in e.PublishedEntities) { if (node.ContentType.Alias == "Vacancy" && node.Parent().Name == "Pending" && node.Status != ContentStatus.Trashed) { var _contentService = Umbraco.Core.ApplicationContext.Current.Services.ContentService; UmbracoHelper helper = new UmbracoHelper(UmbracoContext.Current); var parent = helper.ContentSingleAtXPath("//VacancySchool[@urlName='" + node.Parent().Parent().Name.ToUrlSegment() +"']/VacancyStatus[@nodeName='Live']");
Automated publishing, no UmbracoContext?
I am running the following piece of code on the ContentService_Publishing event which works fine when I click Publish from the CMS however it fails when it is called via an automated publish from a publish At date/time being set on a node as the UmbracoContext is returned as null.
Any ideas of why and a way around it?
is working on a reply...