When using the event ContentService.Published and then calling SaveAndPublishWithStatus within this event how can you stop the Publish event being raised again.
I have a scenario where I am stuck in a loop as on publish the event is calling SaveAndPublishWithStatus which is then raising ContentService.Published event again.
The Content Service accepts an overload that controls whether or not to raise events; I'm wondering if you could set that flag when you use SaveAndPublishWithStatus 'within' the event itself to prevent the loop.
Are you republishing the same item in the event ?, if so if you do not 'cancel' the original event; it will just be published ? ie no need to call SaveAndPublishWithStatus again...
or are you publishing a second item ?
can you post the code so can see what you are up to ?
(looking umbraco source, it looks like the cancellation flag, will cancel the save events, but then it does not appear to be passed to the PublishingStrategy class responsible for publishing and so the publishing events still get raised! :-(.... )
ContentService.Published Umbraco 6.25
Hi,
When using the event ContentService.Published and then calling SaveAndPublishWithStatus within this event how can you stop the Publish event being raised again.
I have a scenario where I am stuck in a loop as on publish the event is calling SaveAndPublishWithStatus which is then raising ContentService.Published event again.
Thanks
Hi Damien
The Content Service accepts an overload that controls whether or not to raise events; I'm wondering if you could set that flag when you use SaveAndPublishWithStatus 'within' the event itself to prevent the loop.
https://our.umbraco.org/documentation/reference/management/services/contentservice
.SaveAndPublishWithStatus(IContent content, [int userId = 0], [bool raiseEvents = true]
)regards
Marc
Hi Marc,
Thats what I thought the raise events property would do, even setting it to false it still raises the ContentService.Published again.
Thanks Damien
Hi Damien
Are you republishing the same item in the event ?, if so if you do not 'cancel' the original event; it will just be published ? ie no need to call SaveAndPublishWithStatus again...
or are you publishing a second item ?
can you post the code so can see what you are up to ?
(looking umbraco source, it looks like the cancellation flag, will cancel the save events, but then it does not appear to be passed to the PublishingStrategy class responsible for publishing and so the publishing events still get raised! :-(.... )
is working on a reply...