[SOLVED] Make 'changes to a Thing' - Display Data

Hi all,

I am building a simple ‘Timer’ feature on my app. The Start button will record the Current time and the Stop button will also record the Current time, both results will be displayed in a repeating group. I can then calculate the amount of time between the start and stop moments, which I call a ‘Shift’. The user should be able to created multiple shifts (which are associated with a specific Job which they previously created) and then finally I will add all the shifts up to produce a grand total amount of recorded time, ie; You have recorded 1 hr 10 mins for your Job ‘Fixing the sink’

Simple Start and Stop buttons:

The start button created a new Shift but the Stop button is not saving the Current time? Any advice on best way to achieve this much appreciated.

Here’s the repeating group:

Here’s the Database set up:

Hi there, @darren.james7518… after taking a look under the hood (yup, I still know where to find your project), the root cause of your issue appears to be pretty simple. In the stop button’s workflow, you have defined the thing to change as time-tracking's Shift, but the time-tracking group (which does have a type of content of Shift) doesn’t have a data source, and it doesn’t look like you are setting the data source anywhere. So, in short, you are telling the stop button to make changes to something you haven’t defined. (FYI… if you had checked the debugger when clicking the stop button, I’m guessing you would have been able to see that time-tracking's Shift is empty.)

There are multiple ways you could address this issue, and one that comes to mind is to set the stop button’s thing to change to a Search for Shifts:last item with the same constraints on the search that you are using to display the shifts in the repeating group.

You could also go the route of addressing the root cause I described above (that being the fact that time-tracking's Shift isn’t defined anywhere), and you should be able to do that by adding a step to the end of the start button’s workflow that displays the newly-created shift in the time-tracking group.

Hope this helps.

Best…
Mike

2 Likes

Thanks so much @mikeloc, I am glad you still have access to my project!

Ok, I have addressed the root cause by adding a step to the end of the start button’s workflow to display the newly-created shift in the time-tracking group and the stop button works perfectly now.

This issue of not having a data source seems to be a recurring theme for me, for some reason I keep forgetting/misunderstanding this concept.

Because the page’s ‘Type of content’ was Shift, I assumed Bubble would know that I am referring to the Shift part of the data base. I did try to set the group’s Data source to Shift but that option isn’t available. In fact, none of my groups have the group’s Data source set and I can’t see how that could ever be set because the dropdown’s options don’t refer to any Data types?

The lesson for me is to remember that if a group is trying to display dynamic data from the database, I need to add the data type onto the group by adding Display data to the workflow.

1 Like

Yes, it does (that’s the whole point)… but it doesn’t know which Shift (that’s what the data source is for)…

I did try to set the group’s Data source to Shift but that option isn’t available. In fact, none of my groups have the group’s Data source set and I can’t see how that could ever be set because the dropdown’s options don’t refer to any Data types?

You have to ‘find’ it… either by doing a search of the database, or referring to something else…

Obviously, in this particular use case, the ‘Shift’ may or may not exist yet, so you can’t set a default datasource to be something you haven’t created yet - hence the need to set it after you create the thing.

2 Likes

Thanks @adamhholmes for that explanation.

I may be wrong but it seems similar to a custom state, telling the browser what data to display.

That makes sense, thanks!