Copied to clipboard

Flag this post as spam?

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


  • Kenny Burns 173 posts 305 karma points
    Feb 13, 2014 @ 10:39
    Kenny Burns
    0

    v6.1.6 - ApplicationEventHandler Issue with Document_AfterPublish

    Hello,

    I have registered a new event on Application Started which looks like:

    Document.AfterPublish += Document_AfterPublish;
    private void Document_AfterPublish(Document sender, PublishEventArgs e)
    {
    //push some stuff to an api
    }

    Now this all seems to work fine - it does everything I want it to - but it is also doing it if the publish in Umbraco fails on validation. So for example:

    • a mandatory field has not been filled in
    • Press save and publish 
    • stuff sent to api (technical term!)
    • error messages regarding validation - node is not published
    So the Document.AfterPublish event seems to be firing whether the node has been published or not. Has anyone else had this issue? Maybe i'm missing something?

    Thanks in advance,

    Kenny

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Feb 13, 2014 @ 11:01
    Stefan Kip
    100

    You should use the new events:

    protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
    {
        base.ApplicationStarted(umbracoApplication, applicationContext);
    
        ContentService.Published += ContentService_Published;
    }
    
    void ContentService_Published(IPublishingStrategy sender, PublishEventArgs<IContent> e)
    {
    
    }
    
  • Kenny Burns 173 posts 305 karma points
    Feb 13, 2014 @ 11:33
    Kenny Burns
    0

    Smashing!! :)

    That works a treat - thanks a lot Kipusoep! :)

     

Please Sign in or register to post replies

Write your reply to:

Draft