Hi all,
The Create operation can be achieved by passing the id as 'NullIdentifier()' to CreateOrUpdate entity action. Then why should I use Create entity action? Is there any specific scenarios where it's best to use Create instead of CraeteOrUpdate?
Again, just to add to Dorine's answer :)CreateOrUpdate always try to perform an UPDATE first, and if it fails (the ID provided was a NullIdentifier() or it does not exists in the database), than it performes an INSERT.As you can imagine, in many situations, it has slightly less performance than doing an INSER (Create) or an UPDATE (Update) directly. It exists to provides simplicity (you can create EDIT/NEW pages with the exact same logic), in situations where performance is not critical.But in most scenarios, when using wrappers to allow a READ ONLY entity to be written from consumers, you will most likely want to check if the ID provided is NULL and then performing a CREATE, or it isn't and you will perform an UPDATE.You may also want to use a SEPARATE CREATE and UPDATE instead of a CREATEORUPDATE action in the specific situation (very edgy case imho) your ID is NOT autonumber, because if the user is not aloud to provide an ID for a NEW record (there is logic to create it), if validation is not correct and they are alowed to send an ID, the CREATEORUPDATE would create a new record with the provided ID, and you would not know the ID provided by the user does not existed previously. In that case, separating the CREATE from the UPDATE would lead the logic to try an UPDATE and fail, without actually creating the record.Cheers!
Hi,
I am not sure you have check below post or not. But I would like to share it,
https://www.outsystems.com/forums/discussion/70966/after-creating-entity-there-is-create-and-createandupdate-is-there-what-is-use-of/
Thanks.
Hi Krishnnambal S,
In my opinion ,when we exposé any API and and need to use POST or PUT method then we use Create and Update Entity action instead of using CreateOrUpdate entity action .
Kind Regards,
Kundan Chauhan
or when we use Processes or BPT then it take only Create Entity action.
Yes,
see answer of Arley Silveira in the post shared by Ajit, it is about performance.
But it can also be about functionality, when you use CreateOrUpdate, you are basically saying that you don't really care if that record was already there or not, just make sure after this action it is.
When you use either the create or the update explicitly, it means you already know in that place either the create or the update is appropriate, and you only expect your software to succeed if the record (isn't / is) already there.
I think most of the time, it is the first (you don't care if it was already there before your action) the other 2 are for specific cases where you really don't want a create to happen if you expect an update or vice versa.
Another aspect to consider, is if you have wrappers in place where all your data manipulations have to go trough. In that case, you can have a 'save' wrapper, that inside has logic to do the right action (either the create or the update) dependent on the situation, so that is also a place where you would use the separate ones, instead of the CreateOrUpdate.
Dorine