Copied to clipboard

Flag this post as spam?

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


  • greengiant83 88 posts 109 karma points
    Jun 10, 2011 @ 16:40
    greengiant83
    0

    Document.BeforeSave fires twice. Doesnt expose current properties

    I set up a class that inherits from ApplicationBase and wires into Document.BeforeSave in the class constructor. When fire the old debugger and watch it, I see Document.BeforeSave being fired twice for each time I press the Save button in the backoffice. Also, when I examine the properties of sender, they do not represent the currently saving items, but rather the previously saved version.  By this I mean I open the document in the backoffice set a textpage's body text to "Version A" and save it.  If I then change the body text to "Version B" and hit save, when my the event is fired the sender's bodyText property still has "Version A" in it.

    I am testing this on a clean install of Umbraco 4.7

    Why is the event firing twice?

    How can I access the properties of the currently saving document?

  • Michael Hyldsgaard 64 posts 124 karma points
    Aug 02, 2011 @ 11:33
    Michael Hyldsgaard
    0

    Did you ever find a solution for this?

    I'm having the exact same problem... :o/

    Best regards,
    Michael

  • Dan Diplo 1459 posts 5623 karma points MVP 3x c-trib
    Aug 03, 2011 @ 17:23
    Dan Diplo
    0

    I'm also having the same problem. This seems similar to a bug that is marked as closed in CodePlex - http://umbraco.codeplex.com/workitem/21847?ProjectName=umbraco Maybe it should be re-opened?

  • Vladimir Knobel 95 posts 170 karma points
    Aug 27, 2012 @ 22:37
  • Dan Diplo 1459 posts 5623 karma points MVP 3x c-trib
    Aug 28, 2012 @ 09:32
    Dan Diplo
    0

    So go vote for it - I have :) - http://issues.umbraco.org/issue/U4-651

  • Vladimir Knobel 95 posts 170 karma points
    Aug 28, 2012 @ 11:38
    Vladimir Knobel
    0

    Done! Thxs for the remainder.

  • Mihai Savu 11 posts 75 karma points
    Nov 11, 2014 @ 01:29
    Mihai Savu
    0

    I have the same problem in Umbraco 4.7.2 (Document_BeforeSave fires twice) but I could use it though.

    The first fire contains the old properties in Sender, while the new properties are not yet in DB, so they can't be loaded from anywhere.

    The second fire

    • the sender contains old properties all the time
    • when the document Text changed, the sender contains the new Text, but still has the old properties
    • the new values can be loaded with Document newValues = new Document(sender.Id);
    • you can check if property X changed between sender and newValues
    • if value changed, then do some processing
    • it's ok to set some properties in newValues object, they will be saved in Umbraco

     

     

Please Sign in or register to post replies

Write your reply to:

Draft