Hi,I'm developing an app to track when an employee starts and finishes work.I want to create a button that, when clicked, saves the exit time (the time the employee finishes work), but does not update the other fields in the record.What's the best way to do this?
@Guilherme Gomes in my first comment you have an example of what Nuno just described. That’s an example of a CRUD action that you can adapt for your use case.
By fetching the record you want to update, all the fields will already be populated with their current values. Then you need to assign the field you want to the value you want. And execute the update in the end.
Hello Guilherme,
Hope you're doing well.
Each entity has entity actions, these will allow you to manipulate the records inside that entity:
But you need a key to identify the record you want to update (usually it's the Id).
After retrieving the record you want, just use an Assign on the field you want and use the Update<Entity> Action.
Kind regards,
Rui Barradas
Although in OutSystems Update Actions updates the entire record, you can do that in two ways.
Go to Indexes and More on the properties:
And there choose to only update "Changed Attributes" instead of "All Attributes".
Hey Nino,
can you elaborate more how to do that after selecting the update behavior
regards,Hiren
Hi Guilherme Gomes,In the entity update action, you can pass only the specific field (e.g., DiscardDateTime, DicardNote) that needs to be updated.
This is happening... It's setting the others to null
You still need to send all attributes. But the internal SQL will only update the ones that are actually different.
The only way of not writing all the parameters is if you create a CRUD that receives the Id and the new parameter, fetches the record, assigns the value and does the update.
Thank you all guys!
I know this might not be the preferred / low code way to do it, but for some specific updates (like moving forward the state of something) I like to write dedicated server actions that use sql to do this one specific task, no need to first use an aggregate for retrieval, only a single sql node.
If I want my code to be even more verbose / explicit, I make actions to move forward to a specific state, that contains all checks to make sure this particular move is allowed. I find that in complex lifecycles of an entity, it is very informative for future developers to be able to
Dorine