Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Apr 20, 2010 @ 18:15
    Ismail Mayat
    0

    Add audit trail to document using api

    Hello,

    I have an action handler and am handling publish event.  I am on certain criteria cancelling event what i wanted to do was after cancel add line to document audit trail.  Just watched umbraco tv vid http://umbraco.org/documentation/videos/for-developers/events/cancel-publishing-with-events and per states it can be done, however video ends before showing how :-}

    PS shameless plug in you dont have umbraco tv get it its awesome!

    Regards

    Ismail

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Apr 20, 2010 @ 18:20
    Stefan Kip
    0

    I have tried using the e.cancel property, but for me it didn't work...
    When I googled some, I found out it's a known bug :-/

    Anyone; correct me if I'm wrong

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Apr 20, 2010 @ 18:33
    Hendy Racher
    1

    Hi Ismail,

    Are you trying to cancel the publish by returing false from the ation handler Execute method ?

    http://www.aaron-powell.com/the-great-umbraco-api-misconception

     

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Apr 20, 2010 @ 18:35
    Hendy Racher
    0

    This post also mentions that returing true / false has no effect:

    http://www.dotnetmafia.com/blogs/kevin/archive/2008/02/13/umbraco-action-handlers-101.aspx

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Apr 20, 2010 @ 18:53
    Hendy Racher
    0

    oops, Aarons post, refers to canceling via the event args as Stefan mentioned. Hopefully both will be fixed in 4.1 :)

  • Richard Soeteman 4052 posts 12925 karma points MVP 2x
    Apr 20, 2010 @ 19:40
    Richard Soeteman
    2

    Hi Ismail,

    Below you find a codesnippet. Basically you need to use the log class and use the LogTypes.Notiify Enum in combination with the documentID to Add a line to the AuditTrail of the document (Log.Add(LogTypes.Notify, sender.Id, "Added To AuditTrail");).

    using

     

    System;

    using

     

    System.Collections.Generic;

    using

     

    System.Text;

    using

     

    umbraco.BusinessLogic;

    using

     

    umbraco.cms.businesslogic.web;

    namespace

     

    AuditTrail

    {

     

    public class AuditTrailEvent : ApplicationBase

    {

     

    public AuditTrailEvent()

    {

     

    Document.BeforePublish += new Document.PublishEventHandler(Document_BeforePublish);

    }

     

    void Document_BeforePublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e)

    {

    e.Cancel =

    true;

     

    Log.Add(LogTypes.Notify, sender.Id, "Added To AuditTrail");

    }

    }

    }

     

    Hope this helps you,

    Richard

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Apr 21, 2010 @ 00:41
    Aaron Powell
    0

    As I mentioned in this post - http://www.aaron-powell.com/umbraco-event-improvments you will be able to cancel Document Save events properly in 4.1

  • Richard Soeteman 4052 posts 12925 karma points MVP 2x
    Apr 21, 2010 @ 08:54
    Richard Soeteman
    1

    @all Cancel on Save will not work(until 4.1), Cancel a publish will work.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Apr 21, 2010 @ 09:28
    Ismail Mayat
    0

    Richard,

    Had a feeling it might be via a log entry but wasnt 100% certain. Karma plus marked as solution.  I am doing cancel on publish so all is good on that front as i am using 4.0.3

     

    Many thanks.

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft