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.
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.
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.
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.
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
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.
is working on a reply...