Copied to clipboard

Flag this post as spam?

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


  • webangelo 107 posts 190 karma points
    Apr 02, 2010 @ 16:46
    webangelo
    0

    Best way to get previous value of a Document Property during the save process

    Hey folks,

    I'm trying to compare the document being saved with its pre-save value to determine if something changed.  I'm trying to use the Document.BeforeSave event, but don't see a clear way to compare what is being saved to what it was before it was saved.  I can't compare it to the Node Factory since the document may not have been published yet.  Does anyone have any insight on how to do this?

    Thanks.

  • David F. Hill 122 posts 242 karma points
    Apr 02, 2010 @ 19:04
    David F. Hill
    0

    Hi,

    You may be able to query the database for the information if it has been saved. That can get a bit tricky, however.

    The data is saved in the cmsPropertyData table and you'll find the node by using the contentNodeId field.

    You'll first need to get the propertytypeid associated with that property from the cmsPropertyType table.

    Hope that's enough to get you started.

    David

  • David F. Hill 122 posts 242 karma points
    Apr 02, 2010 @ 19:20
    David F. Hill
    0

    Hi,

    I re-read your question and realized that you asking about the data before it's been saved (I was thinking before published). Sorry - my answer probably was incorrect.

    If the info has not been saved, you may need to look at an AJAX approach to get the info from the client (browser).

    David

  • Zobayer Rabbi 3 posts 23 karma points
    Jan 13, 2011 @ 07:28
    Zobayer Rabbi
    0

    Hi

    I need to save data from my custom control. Is it the correct way to save data directly to cmsProperTypeData table?

     

    Zobayer

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 13, 2011 @ 08:34
    Dirk De Grave
    0

    No, it's certainly not the preferred way (altho it can be done), you can use the document api to store data through your custom control. Honestly, I wouldn't know what would happen if you'd write to the cmsPropertyData directly... so I'd stay away from it.

    As to getting the info from the document (the pre save values), you could just get the most recent version using the document api again, check what data has changed and then update (save) your new version.

    Hope this helps

    Cheers,

    /Dirk

     

     

  • WestLifeUmbraco 39 posts 70 karma points
    Dec 12, 2012 @ 22:41
    WestLifeUmbraco
    0

    Hi webangelo

    Do you find the solution to the problem?

Please Sign in or register to post replies

Write your reply to:

Draft