I want to stop deleting record which is currently accessed using GetForUpdate.
Please check the following scenario. The record with the name Alan is accessed by using the GetPersonForUpdate action but still, but I am able to delete this record.
This record should not be deleted using the DELETE button from the table as it is currently accessed using GetForUpdate.
The record that is in update state shall not be deleted from table using delete button.
@Pramod Prakash Ghogare ,
in your screenprints you show an action doing a GetForUpdate, and then no actual updates inside that action.
If after that action flow, you return to the screen and hope that the lock will remain in place until your user presses the Save button, you have a wrong understanding of the GetForUpdate.
It only holds the lock as long as you are inside the same transaction. So end of transaction = end of GetForUpdate lock.
Now for what a transaction is and when it ends, depends, but in it's most simple form (and as you are doing the OSMDB exercise, that's the case, I think) the transaction starts at the first database access inside a server action, and ends right before the server sends the resulting page back to the browser.
So by the time your record is shown to the end user for him to edit, that transaction and the lock on the record is long gone.
Dorine
Hi Pramod,
GetForUpdate action locks the record in the database until the transaction is finished, preventing other processes from accessing this record . i e we are using GetForUpdate insted of CreateOrUpdate action.
Thanks for your reply,
but why do we need if condition as its own capable to lock the record?
Hi Pramod ,
You just need to add if condition before the Getforupdate action and compare the user identifier and if it's true the do not do anything and if condition is false the you can delete the record.
if any confusion send me OML so i can do.
If I am setting the condition manually then what is the meaning of using GetForUpdate as it can be done with the CreateOrUpdate action having if condition prior to it?
What is the meaning of following
GetForUpdate: Reads an entity record from the Database through its identifier and prevents other requests from accessing it until it's updated.
lock record means if at the time of GetForUpdate opration any one wants to update on that record same time then this action prevent this type of scenario.
if need more explanation then please read below outsystem documentation.
https://success.outsystems.com/documentation/how_to_guides/data/how_to_handle_concurrent_updates_on_application_data_records/
Hello Pramod,
Based on your screenshots it looks like you are using 2 different buttons and actions for performing these 2 different operations (Update and Delete). So, first a record is getting updated and then you are deleting the same record using that entity identifier. So, in this case GetforUpdate action will not stop you to delete that record, since you are not doing at the same time.
Thanks,
Sachin
can you tell me how to do it at the same time?
I am not sure if you are aware of the concepts of locks in traditional languages, if not please refer the below link.
https://learn.microsoft.com/en-us/sql/ado/guide/data/types-of-locks?view=sql-server-ver16
The same concept applies here as well. If 2 user tries to perform operation on same record it will not allow the second one until first one's transaction get completed. So, getforupdate action will lock the record for second user and does not allow to make any update. This scenario happens in multi user environment.
I retrieved the record from getforupdate action then it should not allow to update / delete until getforupdate action release the record
In that case may be you need to use transactions. However, please go through with the below links which may help you to under this concept.
https://success.outsystems.com/documentation/how_to_guides/data/how_to_handle_concurrent_updates_on_application_data_records/?
https://www.outsystems.com/forums/discussion/76151/getforupdate-lock-type/