We are looking for a way to save a new/modified entity record before it is committed to the DB. Then, another user will call up the modified entity, preview the changes, and then apply the new/modified entity to the DB with all the values, if approved. It is similar to a maker-checker process.
So far, what I have done is to convert the modified entity to JSON using entitySerializationAPI.toJson() and save into a table. Another user can then call up this record, convert back to an entity using entitySerializationAPI.entityFromJson(). But this entity cannot be saved. So I had to use the DataManager to retrieve the existing entity or create a new one, copy the properties from the modified entity and commit this. However, I will lose the original creator/modifier name. Also it does not check if the version has changed from the original modification.
Is there a better way to serialize an Entity for subsequent review/approval and committing later into the DB ?
I think you are using the wrong topic (Solutions Exchange). I don’t know if it is possible for you to change, but I think Support is more appropriate.
About your question: Why not just create a field to control the status of the record? With access groups constraints you can easily control which status are available for a different group of users. And using entity log you’ll be able to track all changes.
Hi Peterson, Sorry for posting to the wrong forum.
The scenario is that we are editing the Master file records. Typically, there is only 1 record for each Primary Key / ID. One solution is to have a separate table which mirrors the Master file table without the Primary Key constraint. When user edits a record, it is saved into the Shadow table awaiting a supervisor to approve the changes. Upon approval, the shadow record is “copied” to the original master file record. But this creates many shadow tables, one for each master file table. So, I was looking for a more “generic” solution that works for all master files.
Such shadow table is the only feasible way to guarantee data consistency. However, you can put sucg “half persisted” entities to a separate data sore in their JSON representation (like Mongo DB) - in this way you will avoid generating additional tables in the main datastore.