I have a custom content approval workflow that worked in Umbraco 7 by subscribing to the content_publishing event and changing a field on the node using the ContentService API to update approval state.
I tested with the Save override that accepts an IEnumerable<IContent> and sure enough it doesn't check published state and worked exactly as I needed to. so if anyone comes accross this in the future _contentService.Save(new List<IContent>() { contentToUpdate}, raiseEvents = false); works as of Umbraco 8.6.3
Thanks but unfortunately not, the save method has a check for PublishedState, interestingly enough it looks like the method for saving multiple content items doesn't have that check.
For now I'm still listening to the published event and republishing if I need to, but I'll try on a list of content tomorrow and report back.
How can I save IContent in the publishing event?
I have a custom content approval workflow that worked in Umbraco 7 by subscribing to the content_publishing event and changing a field on the node using the ContentService API to update approval state.
In Umbraco 8 using the .Save method
I get the following error
Cannot save (un)publishing content with name: test - and state: Publishing, use the dedicated SavePublished method.
But I can't seem to find that method anywhere, is there another way to save while PublishedState is Publishing?
I can get around it by subscribing to the published event and using SaveAndPublish but that leaves two publish events in logs.
Hi Kevin.
I dunno if it helps, but try use
_contentService.Save(contentToUpdate, raiseEvents = false);
I tested with the Save override that accepts an
IEnumerable<IContent>
and sure enough it doesn't check published state and worked exactly as I needed to. so if anyone comes accross this in the future_contentService.Save(new List<IContent>() { contentToUpdate}, raiseEvents = false);
works as of Umbraco 8.6.3Thanks but unfortunately not, the save method has a check for PublishedState, interestingly enough it looks like the method for saving multiple content items doesn't have that check.
For now I'm still listening to the published event and republishing if I need to, but I'll try on a list of content tomorrow and report back.
is working on a reply...