Data is not being written to firebase

To save the data to the database, I did the following:
I created four variables, three of which were empty lists and two of which were integer variables.

I have three card views for adding hypermarket, product, and brand.
Before adding, check that the text boxes are not empty for each one.
If they are not, I call Firebase to get the value.


Para o Got Value eu criei uma procedure para cada um dos cadastros
Procedure Got Value:

Procedure hypermarket:

Procedure product:

Procedure brand:

The “registration type” variable identifies whether the record will be of the hypermarket, product, or brand type.
The “verify registration” variable determines whether the data being recorded already exists in the database to avoid duplication.
It turns out that it’s not recording any of these types.

Hi Carlos,

First things I see that can be corrected are:

  • instead of doing if true and txt_text_hypermarket.Text = "" just use is empty directly
    text_isEmpty

  • we can remove the variable registration_type because you can filter the function to use directly in gotValue
    if the tag is /Registration/brand_list you use the brand function,
    if the tag is /Registration/product_list you use the product function,
    and the same goes for the other one.

  • when you check if the data is already present with the functions you could instead

regarding writing to the database, first check if you are actually adding something, add a notifier that shows you the hypermarket list before sending it

I did, but nothing appears. I’ll put the aia here and see what’s wrong.
The screen/block is this:

orcamento_compras(1).aia (262.7 KB)

It’s okay to use this bank. I’ll create another one.

I reduced the code a bit (I’m sure it can still be improved in terms of logic).

Here’s what I did:

we always call a getValue of the relevant node,

and in the gotValue we call the function addItemToFBList.

Since you were running the same function for all nodes, I turned it into a single one, and we pass it:

  • the reference tag, so it can rewrite in the tag on Firebase (tag)
  • the list present on Firebase (value)
  • and the component (textbox) that contains the value to be written to the DB.

The function

  • saves in a local variable local_list the data present on the DB; if it doesn’t exist, it creates an empty list
  • in textBoxValue it saves the text value of the component we passed to it
  • if the value already exists in the list, it informs the user that TextBox.Text already exists” (let me know if that works for you)
  • if the value doesn’t exist, it adds it to the local list
  • writes the list in the DB in the tag node
  • message dialog
  • then clears the textbox of the component we passed to it

Let me know if this can be a solution, otherwise we’ll come up with something else :grin:.

Perfect. I’ll run the tests here and let you know.
Just one question. In the post I accidentally deleted about the popular hypermarket, product, and brand spinners, which has already been resolved, I was getting an error when starting the screen. That is, since there was no data saved in the database, the companion would freeze. To prevent the user from entering this screen and getting this error, is there a way to perform a validation beforehand, such as when it verifies that no data is saved, it displays a message that they must register first?

You mean this one?

Anyway, I’ll reply to you in private now because this question is not part of this post :grin:

can you show us permission you given on firebase? bcz to read/write you need to make them true from the firebase rules.

Gianluca, I wanted to save my tag this way, because it now has the Firebase authentication identification code. Is it possible in this structure that you gave me?

For this here in the case of Get Value:

And what would the Got Value and procedure look like?

Hi Carlos,

You should be more specific.
When using a node with the UID, you should also use rules, but they don’t work very well with the Firebase Authentication component.
Unfortunately, the native Firebase component doesn’t pass the auth token during operations, so it wouldn’t be very useful to use a UID in the middle of the nodes.
However, not all is lost, the legendary TIMAI2 has made a guide with all the details on how to use rules in Firebase through the Web component.

Hey Carlos, sorry about that :man_facepalming:
I misread and linked you the wrong guide.
This is the correct one

thanks to :raising_hands:Tim:raising_hands: