Search code examples
wakanda

On Wakanda Server, how can I access the current value of an attribute during a save / validate?


I am building a "change log" feature for a Wakanda application. During the validate or save events on the server, I need to get access to the existing value of the attribute as it is in the datastore so I can record a before value and an after value.

At this point, the only solution I have found is to run a query in the validate event and retrieve the entity fresh from the datastore. Perhaps this is the best / only solution?


Solution

  • Yes, the solution is to run a query in the validate event. In the validate event function the word "this" refer to the new entity that will be saved. You can get the existing entity by running the query (find()) : ds.Item.find('ID = :1 ', this.ID);