Copied to clipboard

Flag this post as spam?

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


  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jul 16, 2013 @ 08:50
    Stefan Kip
    0

    v6.1.2 - which properties' values changed

    In umbraco v6.1.2, how do I find out what properties' values have changed with ContentService.Saving and/or ContentService.Saved?

    In Content.Saving the value has already changed to the new value, while the documentation states "Occurs before Save"...

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Jul 16, 2013 @ 10:12
    Peter Gregory
    100

    Are you looking at hte IContent item in the the saving event? I believe you might be getting confused that the item you are looking at in the saving event is the item that is to be persisted and not the unmodified item.

    You would have to compare it back to what the orginal looked like.  Maybe keep a copy or during the saving event load a new instance of the item and compare the properties to see which ones dont match.

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jul 16, 2013 @ 10:54
    Stefan Kip
    0

    Yes you're right Peter, it's the in-memory version of the IContent object which is to be persisted.
    Fetching the latest version and comparing it to the current IContent object works:

    void ContentService_Saving(IContentService sender, SaveEventArgs<IContent> e)
    {
        foreach (IContent iContent in e.SavedEntities)
        {
            Content content = (Content)iContent;
            IContent previousVersion = sender.GetVersions(content.Id).OrderByDescending(x => x.UpdateDate).FirstOrDefault();
        }
    }
Please Sign in or register to post replies

Write your reply to:

Draft