Behavior of a global variable

I would like to understand why my Global variable doesn’t work outside of Got Value.
If everything went well, within the Got Value event, there would only be the global set line Venda to…
All other lines are just an attempt to find where my variable got lost.
What I wish:
As soon as my screen starts, I need to get the amount of sales made for a product on the day, that is, how many times have I sold, for example, WATER today?
I understood that the size of the list offers me this value and so far everything is ok. And that would be enough for me.
Hence the global set line sell to length of list get value. And that’s perfect. As I said, that was enough.
But, as I have to check other products as well like Coke, Hot Dog … I need to run this same routine several times and then I decided to create a specific variable for the product.
So, going back to the pega_nr_venda procedure after the nr_agua call, I try to put the value of the global variable Venda (which until then was perfect) in the global variable Venda_agua and move on to the next product.
That’s when I realized the value was lost. The global variable sell outside the Got Value block, lost its value.
This is evident in Label 4 where it takes on the value 1 which is its initialization value.
Why does it happen? How can I continue with the value?
Detail: I already tried to put global set venda_agua to label3.text. It doesn’t work either. If it worked, just give a visible.false on label3 and that would solve it.
Thank you for your help.

image

since you have added the procedure in screen initi, it will return zero only. actually that global variable will store the firebase value after firebase get value triggers. so see your algorithum

I created a button to call the procedure and the inconsistency persists.
Before clicking the button, I have this…

image

After clicking the button, Label4 still gets the old Label3.text

image

I can’t understand this behavior

Even so, thank you very much

Order of things…

image

I’ve done that my friend. But, when I go to write this variable in the DB, it is no longer with the defined value.

When putting inside Got Value as suggested I will have a problem as I will need to do multiple checks for water, coffee, hot dog, soda…

The only change will be the modification of the WATER TAG to COFFEE TAG, HOT DOG TAG…

Thank You

Actually, can you explain what you wanna achieve?

I am making some sales of some products. That way, on sale 01 I can sell 3 bottles of water, on sale 2, I can sell 1 hot dog and on sale 3 I can sell 1 bottle of water again.
So my DB would look like this:
WATER
|-------- 1: 3
|-------- 2: 1
HOT DOG
|-------- 1: 1
If the application closes, I need to continue selling, get the number of the next sale of each product. So, I need to get that for water, I will do the 3rd sale and, for the hot dog, I will do the 2nd sale.
Taking the length of the list, I have this information, but outside of Got Value this value is lost and I can’t record it on the next sale.
Was it possible to understand? I’m not understanding why the value is lost when exiting the Got Value block.

I understand but the problem is you shouldn’t set the single digit as tag value. If you want then just set it as along with 0 . I mean
01: its value
02: its value

Due to this reason you didn’t get proper response in get value event

WATER
|-------- 01: 3
|-------- 02: 1
HOT DOG
|-------- 01: 1

But, I have the correct size of the list that gives me the next sale number. However, when I write the data to Firebase Store.Value, the variable that received the size of the list is lost

suggesting the above just to overcome this issue
.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.