Just discovered Saltcorn a week back. Am lovin it.
Experimenting with trying to fire an update event on button click. What is the right format for the JSON payload? I only wish to change one field (called checked_out - bool type) in a row from within a "Show" view. Can I send a partial JSON and the rest will get filled automatically? Or do I need to supply the complete row including ID, if so, how do I populate the ID of the currently "Shown" row in JSON?
If I send {checked_out: true}
, the event is triggered and logged but no change in the table. If I give checked_out:true
, it complains of syntax error.
I have since tried run_js_code as well with the following code:
emitEvent("Update", "books", {"id":row.id.toString(), "checked_out":true});
The event is logged, but nothing changes in the table.
I guess my understanding was not correct regarding events. I thought emiting an Update event would cause an Update to occur. Its the other way round I suppose. I managed to update the table/field using Table.findOne followed by updateRow function (had to reverse engineer from code as the documentation is silent on the API).
Later I found that 'table' object is already provided, so there is no need to 'find' it.