Create record: how to add page variable to firestore DB?

hi there,

how can i put a page variable into create record flow that it’s saved on the backend (firestore)? i explain my challenge:

  • have page variable with id from tabbed item (category list)

  • have 2 lists on the page (categories & subcategories)

  • page mounted shows both lists with all records

  • tab item in category list shows only related items in subcategory list

  • toggle to swipe in a form to add new record

so far works pretty well. but now my question: how can i manage, that the page variable gets a part of the create record flow and getting stored in the database?

name: comes from the input field
categoryID: have it in page variable, but can’t bring it into database record

thanks a lot in advance …

If I understand the question, you want to update a record in firebase with a value you have as a page variable?

If yes, then you have to delete the FB record and create a new one, using your new value, using the RestAPI. I´m doing this in my application. As far as I´m aware you can´t update a single field in a FB record.

thanks for your reply.

i want to create record (not update). the firestore image above is only to see db-schema. i’m not using restapi - i use data resources firebase/firestore. therefore i have a data variable (addSubCategory), type new data record:

categoryID: i get value from page variable

subcategory name: bind with data variable (addSubCategory):

button (add subcategory) has the flow:

subcategory name: bound to data variable (addSubCategory) to create a single record (works)
categoryID: bound to page variable to catch the value, but cannot bind it to the create record flow *

  • i guess this needs to be somehow combined with formula, but no idea how ?!
    it is all about this tiny part here, because i want the categoryID to be stored in the db without typing it, as this value is available in the page variable.

by the way: with data resources firebase/firestore it is possible to update single fields in a fb record.

Have you tried binding it as a formula, and then just selecting the same page variable? You might get a warning error but just ignore it.

When I tried updating a FB record some months ago it didn´t work and there were some forum comments stating just to delete / recreate. I guess this has been resolved now. What I´m doing works ok for me, maybe I will retry the change record at some stage.

Hi there, just trying to help out. For the brief solution skip to the bold text.
I would suggest using a addSubCategory page variable and bind the input field of the name to that page variable’s .name property.
Why so? If I get it right from the images, on page load you initialise a new data record addSubCategory which is an object with a few properties, one is “name”. I am not sure how the app would update the data.addSubCategory variable on input change, but what I know for sure is that it would update a pageVars.addSubCategory basically realtime. This makes it easier to catch and check if the subcategory is populated with the right data.
If you have a pageVars.addSubCategory on the button tap you could do the following:

Create Record and then in the Record Select binding type screen choose “Object with properties”.
Here you can set each of the data resources properties (that you defined under the data menu during configuration of the resource) individually. Something similar, just the title would be "Create record"

*Honestly, for simplicity reasons and cleanliness I usually have a page variable in which I set all the properties to what I want prior to “Create record” and then pass on the single created, evaluated and ready pagevar to the “Create record” flow function. As shown here as well:

Just a quick reflection to this statement:

I have been using the platform with Firebase connector since around September last year and experienced zero errors with any of the requests. In fact the connector makes life so much simpler.

1 Like

I had some issues with update back around September so I just used RESTAPI. Good to know I can go back and re-engineer at some stage to do updates.

1 Like

:+1: thanks for clear explanation. solved my problem in under 1 minute. in fact i did not have a “problem”, i just did not see the simple solution. i am in here since about 10 days - it’s a great journey.