I hope that you are well. I am hitting a bit of a brick wall on something that I sense should be deady easy and I am wondering if you could give me a quick hand. Throughout my app in AB1 I have firebase firestore queries that pull back query results and I populate report objects with the response data. To edit individual records, I pick up the onclick event and edit each record in an edit view and all is good.
Now I have a couple of views where the data returned is for a single record such as in the case of a user profile view. I want to pull in the single record when the view is loaded and populate several fields in the view such as firstname, lastname and email. I have the following code running on view show:
This properly pulls in the record and shows the following in the console:
I think that I need to parse this object in order to obtain the individual field values in order to place them into the view for editing but I am struggling with the proper approach. If you could point me in the right direction it would be greatly appreciated.
I think you are doing well. Once you get "doc.data()", you can simply place that object's properties where you wanted. For example, in a way like this:
Something like the above can work. Even you can avoid the "userData" local variable and just access the "doc.data()" like "doc.data().firstname". Just like you prefer.
Ah, that is perfect, it worked. I wasn't declaring the userData variable and that was my problem.
Many thanks as always! Pete
You are right, I just tried it. I was trying to put the field in the brackets 'doc.data(firstname)', not 'doc.data().firstname' as I should have been. I figured I was making a dumb mistake and I was.
Well, all days we can learn something. :-)
Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.