This one seems like should be easy so hopefully it is?:
Entity qodlysource is on my page. When user clicks a button, a function is run to save the updated new entity qodlysource.
If the save is successfull, the function returns a save successfull message, else it returns a save error message.
If the save was successfull and the entity was saved to the dataclass and given an id, do i need to return that entity to the page so that any subsequent updates to the entity that the user makes and and re-saves on the Page, do not keep creating new entities?
I feel like my save function needs to return both a message, and the updated entity back to the page if the save was successfull, but not sure if that’s the case and how best to do.
Thx for pointers…want to make sure I get this concept right.
If it does return the newly saved entity with id back to the qodlysource entity variable on the page automatically, that would be great. I ran into something where it looked like that didn’t happen. I’ll try some testing on my own.
I tested. It looks like if you do not return the saved entity back to update the page qodlysource entity, you will keep creating new entities each time user updates and saves. So if a user enters values for some entity attributes on the page, passes the entity to a function that saves it and returns a string result message, then updates some of the entity atrributes and saves again, a new entity will be saved each time.
Saving a new entity and not returning the saved entity back into the qodlysource entity seems to leave the entity on the page with no ID. Once the qodlysource entity is saved, if it is returned back to the page qodlysource entity, the page entity will now have an ID so will be updated instead of new on subsequent saves. It looks like that how it works. This means my save function needs to return the saved entity back to the qodlysource variable if save went fine, and return a save result message to be displayed in the result dialog. That seems tricky.
anyway, option “b” is to assign an id when you create the record (if you’re using uuid’s for the keys, you can just do that), then after saving it, do a .get() with the uuid to reload it, right?
(i really should not answer when i’m not in front of q - makes me look like an llm, making crap up)
I can do something to make it work, it just seems like extra work. One of the related sticky issues I have is returning multiple values back to the page with a function if one of the vlues includes and entity or entity selection. If the function could return an entity and a message in an object or collection, that would be doable, but iI have had challenges with that. Your tip sounds good, but I’d like to just have Qodly handle the ID generation as i can screw things up. Will keep at it.