Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Damien 36 posts 162 karma points
    Dec 14, 2015 @ 11:29
    Damien
    0

    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

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Dec 15, 2015 @ 07:45
    Marc Goodson
    0

    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

  • Damien 36 posts 162 karma points
    Dec 15, 2015 @ 08:26
    Damien
    0

    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

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Dec 15, 2015 @ 11:14
    Marc Goodson
    0

    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! :-(.... )

Please Sign in or register to post replies

Write your reply to:

Draft