When I use GetForUpdate<Entity>, it locks my entity. My question is when it release the lock?

I search the answer for a day but can not get a deserved one

once the entire transaction is complete, the whole action or screen action the getforupdate is called from.  You may be able to force a release by using the commit action though.  (System) > Server Actions > CommitTransaction

Hi Pham :),

As stated in the documentation "the GetForUpdate"(https://www.outsystems.com/help/ServiceStudio/9.1/index.htm#t=Using_Data%2FGet_for_Update_Action.htm) action locks the record in the database until the transaction is finished, preventing other processes from accessing this record".

So, the 2nd transaction accessing the same row waits for the lock from the 1st transaction to be released - which happens implicitly when the transaction / request ends (web service, screen action, etc). 

You can use the built-in CommitTransaction action to end the transaction sooner, otherwise it's committed when the request ends.

I hope it helps.