Reputation: 4243
Let's say I want to perform custom logic only, say, when a user's verified
field changes from false
to true
(in order to make sure they are allowed to be performing this operation). Is there a way in Cloud Code to see what the 'current', i.e. about-to-be-overwritten value of a field is?
Upvotes: 3
Views: 817
Reputation: 16874
I would look at changedAttributes()
, previousAttributes()
and previous("columnName")
to see if these have been exposed in the beforeSave
handler yet.
Update note: none of those methods help.
The only other option I've seen in some older questions is to check object.existed()
and in that case do a get()
request to load the original values before the save. Obviously this causes 2 API requests per save.
It would be great to hear back if the changed/previous methods work.
I have since done some more thorough testing, and the only option is to get()
the previous version of the record. Nothing else works. This of course requires that you do it in the before-save handler.
Upvotes: 3