Copied to clipboard

Flag this post as spam?

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


  • andy_rose 91 posts 117 karma points
    Aug 02, 2011 @ 16:07
    andy_rose
    0

    Can I get the before and after values of a property during a documents save event?

    I'm not sure if this is possible but when I hook into a document's save event can I easily get the before and after properties throught the api? I would guess that this would involve the versioning aspect of Umbraco; I was hoping someone may have already tackled this and give some insight into how best go about it.

  • Richard Soeteman 4045 posts 12898 karma points MVP 2x
    Aug 03, 2011 @ 07:43
    Richard Soeteman
    0

    Hi,

    You might want top read this blogpost which is telling that it should work since Umbraco 4.6.I haven't tried this myself since I always thought it wouldn't work because properties get saved immediatelyafter they got a value assigned.

    Hope this helps you,

    Richard

  • andy_rose 91 posts 117 karma points
    Aug 03, 2011 @ 10:35
    andy_rose
    0

    Thanks for the link Richard, the solution I came up with in the end was to hook into the Document.BeforeSave event, retrieve the property value I was after and store it in Session so that I could access it from the Document.AfterPublish event and this does appear to be working as expected. During the BeforeSave event the property value is the original value and in the AfterPublish event it is the saved value which allows me to make the comparison.

    Overall it seems a little heavy handed but I guess that is just how Umbraco works and it achieves the desired result.

Please Sign in or register to post replies

Write your reply to:

Draft