I’m using a form in UI Builder to let users update their user name. In the users table, “email” is the identifying element and I’ve configured “name” with the “unique value” constraint.
When I’m updating the users table with an already existing name, an exception is thrown, which is correct. However, after that, the codeless block “Get current user” returns the invalid user name.
My expectation is, that the “Get current user” still contains a consistent state as defined by the database table constraint. Do you agree?
Your understanding is correct (the users table is not updated but the internal runtime representation of the current user).
The code shown is the submit event for the form on page “account”.
My appId is 5BDF0E64-9F03-6F8E-FF75-0E183AF61100
Regards,
When you set “get current user” to desiredUser, you are actually passing a reference to an object.
And desiredUser is the “get current user” actually. Thats why, when you change something in desiredUser it is changing in “get current user” too. This is a property of the engine that the codeless is running on.
To get predictable behavior you should make a copy of object. Here is one of ways.
One thing though: “Get current user” sounds like a function returning the currently logged in user.
It seems, that this is not true, and “Get current user” is just an object which has been filled at some point in time, correct?
Regards
Hi @viktor.liablin ,
I’m still struggling with the semantics of “Get current user” …
If I’m changing the users table using the block “Update User”, the object “Get current user” still reflects the old state before the update. Thus, “Get current user” is inconsistent with the users table.
In my opinion this is a bug. All successive uses of “Get current user” return the wrong result. If you offer a method “Update User”, this method should change the result of “Get current user” accordingly. Otherwise, I have to adapt the object “Get current user” by myself with the wierd statement Set property in: (Get current user) property ...
So my request is: The method “Update User” should adapt “Get current user” accordingly, if the update is successful.
We’ve just updated cloud servers with a fix for the issue you described above. Now the Get Current User block has the reload checkbox which will help you to display updated data. Could you kindly let us know whether fix works for you well?