How do I force a refresh of the user record on the client-side after updating it on the database/server? I have a few spots of my app that are like this:
- Use “Update User” block to change user record
- Use “Get Current User” block with “reload” checked to update the user record loaded for the user
- Navigate to a different page
- Use “Get Current User” block
- Uses old version of user record, rather than updated one
I understand I can change all of the “Get Current User” to “reload” and constantly fetch a fresh user record from the database. However, I presume there is a better way to just refresh the user record that is loaded, rather than refresh it each time.
You could use the real-time database feature to get a callback into your app whenever user record changes with the Update User block. Here’s the documentation on the conditional update with the real-time database:
https://backendless.com/docs/js/rt_conditional_delivery_update.html#codeless-reference
That seemed a little complicated for my use (I don’t know how to use callbacks or the real-time database), so I resigned to just using a fresh “reload” booleon for user records whenever I need the few attributes that change after account creation. However, I hit another snag.
Users collection shows this test user has a “name” value of “David King”
But when I print the User to console, it shows “name” as null
It does this even when I check the reload booleon to get the value straight from the database that shows the value as “David King” not “null”
I’m wondering if my actual problem is just that the “reload” booleon stopped working for some reason?
Hello, @David_King
Please provide the app ID, container and page name so we can better understand your problem.
Regards,
Serhiy
33ECD666-2D72-4A69-B84B-AF9042E95A63
Container: Test
Page: Contract
Flow: When you click “Save Signature”
It seems to work if name = “David King” when the user logs in, but the “reload” booleon on “get current user” does not grab a fresh user record from the database if the user record has changed.
I found a workaround. I just did an actual data API call to fetch the user record from the database.