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?
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).
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.
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.
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
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
Hi
I need to save data from my custom control. Is it the correct way to save data directly to cmsProperTypeData table?
Zobayer
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
Hi webangelo
Do you find the solution to the problem?
is working on a reply...