The number of cats owned by the current user is not updated in real time

Good afternoon!
I have a page that displays the number of pets of the current user. After clicking on "Delete , one pet of the current user is removed from the database. The problem is that on the page, the number of pets is only updated after the page reloads. I have a question, why the number is not updated in real time?




Here is video:

Hi there, @olgahvesko… one way you can go here is to put the text element in a group, set the group’s type of content to number and set its data source to the search for cats with the count, and have the text element display the Parent group's number. Then, when the button is clicked, delete the thing from the Cats data type, and add another action that displays data in the group, with the data to display being the same search with the count.

Hope this helps.

Best…
Mike

1 Like

Sorry, I didn’t quite understand that sentence “and add another set that displays data in the group, with the data to display being the same search with the count”.
I did this, but maybe it’s not the right one

Sorry, it was supposed to say “action” instead of “set”… I fixed that. What you are showing is exactly what I meant, though, so I’m guessing it is working as expected now, right?

I did what you said, but it didn’t work



That definitely looks like it should work.

Try running the workflow in step-by-step mode and see what the debugger says.

Why is the last item I want to delete empty?


There are records in the database

I replaced the last itemt with the first item, and it worked! Thank you very much!

Although your method does not work when you click the “Delete” button again. I recorded a video. For some reason, the program incorrectly identifies the first element: I have it lapka1, but the program writes that the element to delete lapka2

What you are trying to do should be super easy. I mean, you are simply trying to delete something and then get a count of the remaining items… it doesn’t get much more basic than that in Bubble. But why are you using first item or last item? Don’t you want to delete a specific thing instead of just the first or last item? What are you trying to do from the user’s perspective?

OK, but does it really matter which element (the first or the last) I want to delete if the method you suggest fails when I press the Delete button again?

Nope, it probably shouldn’t matter, but it is mattering, apparently, and without being able to see everything you have going on, I don’t know why it’s not working.

I will try the method you suggest under different conditions and report back later

It makes no sense how the number drops by 2 in your video. If anything, I might expect the number to stay the same because I guess it’s possible that the second action in the workflow could complete before the system is able to search for and delete the item in step 1 (which is why what you are actually trying to accomplish might matter because maybe you don’t need to be searching for an item in step 1). But again, I have no idea why the number would drop by 2. You could try inserting a pause between the first and second steps to see if that helps.

This topic was automatically closed after 70 days. New replies are no longer allowed.