How do you refresh DB value in real-time? Number Counting App

Hello Again Everyone! I always appreciate all the helps from the community.

I’m building an app that counts up every time a button is clicked. Clicking a green button will count up the number right next to it. The same goes for the red button.


I got to the point where clicking the button “updates” CountYes property in the firebase DB. Which is great! I can confirm in real-time in the Firebase DB that the number has increased by 1.

And for the number counter (number next to the button), I did set “current.CountYes” since CountYes is the property that I’m writing to and want to read from.

I have two challenges:

  1. Although the Firebase DB shows updated value after clicking the button, the number in the UI won’t increase right away. Example) when CountYes = 0, it becomes CountYes = 1 in the Firebase DB after clicking the button, but it remians “0” in the UI. When I go to another page and come back, then it shows the updated value of “1”. What can I add that will show real-time updated value when a button is clicked?

  2. For now, the button only updates once. Example) current value = 0. If I hit button, it updates the DB value to 1 (counter number current.CountYes is still displaying 0 in the UI). When I hit the button again, it won’t increase it to 2. However, if I go to another page and come back, the UI shows 1 and it allows me to click and update the value to 2, but again, it won’t update to 3 if I click again. Do you have any suggestion why this could be happening?


Two ways:

1 with a delay that fetches data every x seconds. But this will count as a read and some DB providers may charge you when you reach XXX numbers of reads per day or month.

2 with a page variable. Your 123 number in the screenshot should be bound to a pageVar (instead of a data var I presume). Assign the formula NUMBER (repeated.current.CountYes)+1 to that pageVar.
Thanks to the two-way binding possibility enabled by Appgyver, you will see the number 123 increment as you hit the thumb-up button.
Then here, you will have to bind the CountYes field value to the pageVar instead of the formula.

I think I did not miss any step here. Still quite new here so hard to advise without your screen in front of me. Hope this works.

Thanks @Fred_Kuzyk. I followed your method 2. I created a page variable called “CountYes” and assigned it to Number Counter (123 box). Then for the click button, I added “Set Page Variable” and added “NUMBER(repeated.current.CountYes)+1.”

Would you review the video below? Now all the counters are showing the same number. Where could I have configured something wrong?

Screenshot for the “Update Record” logic for the button.

LOL, yes indeed, I realize you have a list with a repeat… :upside_down_face:
I don’t master this part now, but I would try with a pageVar that is a list of objects with the same schema as that of your 123 number.
I’m not going to be able to help further here as I do not know appgyver by heart enough and I need the screen to explore and find it out.

@Fred_Kuzyk Thanks for the help! I will try the list of objects pageVar and share here if I have any success!

To update in realtime is this:

  • Just use the “Set repeated item” flow function after the update record flow connected to the first output (which is successful)
  • then set the desired property to the "outputs[“update record”].response.desiredProperty

For the incrementing value you could in fact do this best with this formula in the “Update record” flow:

SET_KEY(FIND_BY_KEY(data.listOfObjects, "id",, "desiredProperty", item.desiredProperty+1)

This would find the current object in the list of objects that you repeat with, that means that it would pass on to Firebase update flow all the properties that are already set and would modify the one property that is the “desiredProperty”.

Hope this was clear.


  1. “Set repeated item” flow function worked for updating the number in real time!
  2. My desired property is “CountYes.” Would you review if my formula is correct?
    => SET_KEY(FIND_BY_KEY(data.MindfulnessCollection, “id”,, data.MindfulnessSingleData.CountYes, data.MindfulnessSingleData.CountYes + 1)

Would you review this video? Recording #67

When I click the button, now it the counter goes up in real time! (which is awesome!). However, the item name disappears, and the clicking the button is not updating the counter anymore. I get the Patch 400 error in the Console.

However, when I go to another page and come back, then clicking the button increases the counter again. Is there any area where you suspect of an issue?

Should be the same issue as in the UID thread…

SET_KEY(FIND_BY_KEY(data.MindfulnessCollection, “id”,, "CountYes", item.CountYes + 1)

I will spend some time learning more about the “item” in the documentation.

I tried the code you suggested and got the following validation message:

  • Unknown type cannot be assigned to number type
  • Unknown reference “item”
  • Invalid “+” operation with number type
  • Unassignable object property “CountYes”

Would you advice me how I could correct these validation issues? Thanks!

You will find the correct syntax for item under the Currently repeated data items in the left menu.
Also what is the type of your CountYes var? You’re using NUMBER(repeated.current.CountYes) so maybe try NUMBER again in this formula if the item fix does not sort the unknown type issue.

1 Like

@Mihaly_Toth @Fred_Kuzyk Would you be able to jump on a 10 to 15 minute video call to help me out? If you could, I would love to reward your time with small compensation!

1 Like

I don’t want your money but maybe I can help in the morning tomo. I’m in Europe CET.

I really appreciate it. I’m in the US EST, which is 5 hours behind. Do you have any time availability in the early afternoon on Saturday or Sunday?

EST is 6h from CET
5h is UK.
Not possible tomo afternoon for me / morning for you?
I can try sat afternoon but can’t guarantee.

How about between 3 PM and 5 PM your time? That would be 9 AM to 11 AM my time. Do you have 10-15 minutes between this time? Thanks.

I’ll be busy with Mihaly in the afternoon actually but I can find a slot. Message me your email so I can bip you and send you a google meet.
It will be quick. Either I understand the problem and can fix this or I don’t and I can’t fix.

1 Like


Here is the formula you need after your update flow function.

MAP(pageVars.droplist, IF( ==, SET_KEY(item, "thumbsup", outputs["Update record"].response.thumbsup), item)) 

1 Like

Did Shankar’s solution work?

Hello @Fred_Kuzyk, thanks for checking up on me. I missed @Shankar_Gomare’s message. I’m looking at it now and trying to understand what “thumbsup” means by looking through some AppGyver documents. I will share my latest update here shortly!