Hello
I’m attempting to pull a specific record from the Backendless database and apply data elements from that record to specific fields in the UI. In the screenshots I’ve included my current logic as far as I could figure it out, loading the database object to a variable and then trying to extract specific elements from that record and set the properties of the fields in page data.
The “Get property ‘email’ of ‘Get current user’” is used to match the current user to the email address that is in the UserProfile database. This works correctly as expected but to then apply the rest of the data elements from that records I can’t seem to get working.
All of the Backendless tutorials on database record retrieval show data being applied to a dynamic list which is not what I need in this case.
Database name: UserProfile
Please assist with the logic of how to make this work or let me know if you need more information
Regards
Hello @Armandt_du_Preez,
the Loas Table object
block will return you a list (array) of the object, not the single object.
Even if you specify the where clause which will filter records to return only one object, it will be returned in an array.
Thus you should access the first object in the list to get a UserProfile or the better way to do it is to use the following block which will return a single object without wrapping it into an array:
Regards,
Stanislaw
Hi Stainslaw,
Thanks for your response. I used the block that you recommended and it does successfully pull data from the database but as the block describes, it only pulls the first record in the database and I can’t see a way that it must pull only the record of someone with a specific email address.
If this were SQL I would have written something as follows
SELECT name, email, location, bio
WHERE email=‘john@email.com’
I hope this clarifies my intention in this query
Sorry, I didn’t notice that the “Get first object from table” block misses the where clause
input.
We need to fix this as it should support it, but for now I recommend doing the following:
Regards
Excellent thank you
This works as I need it to and I can now apply specific data items of a specified record to the fields I need.
Regards
Hey @stanislaw.grin have you guys fixed your get next to include a where clause? or how do you recommend getting a single record/object?
Hi Joel,
The screenshot in @stanislaw.grin shows how to get the first object. I also just responded to your other post where you asked this question.
Mark