Creating a change log for field changes using event handler?

I have several database tables in my app that I want to log changes for.

That is, when a date is changed, I want to write it to a changelog table, so that I can show all changes done for a single object.

I know there are many ways to do this, but I was wondering if it is most efficient to have an event handler write changes to the changelog table after a successful write, or if that is totally not the way to go.

Has anyone done something similar and can give me some advice here? :slight_smile:

Hi @Egil_Helland ,

Variant with event handler will be the best for this task since it is easy to implement and will be executed by Backendless with means that network latency will have smallest impact on API calls from your code.

Regards, Andriy

Suspected as much. Is there a way for me to get the fields that change value using update calls for a table? Any docs on this that I should review/get inspired by?

@Egil_Helland ,

Unfortunately there is no option to get diff for updated object. You will need to do it yourself.
You can try to base your logic on beforeUpdate event handler so you can access both, old and new, versions of object at the same time. In such case you will need to load by ID “old” version while “new” one will be passed directly to event handler.

Regards, Andriy

Ok. Is there a way to log to RT log or similar when writing even handlers? Prints are not shown it seems at least, but can I use log calls?