Forum Academy Marketplace Showcase Pricing Features

Best way to achieve showing a list of recently viewed items to a user

Hi there,

Hoping for some help/inspiration!

My application is an internal application which is used to manage property valuations and sales, all released and working incredibly well (isn’t Bubble bloody amazing!) apart from one thing that has stumped me for a few days now and I know there will be a really simple solution but I haven’t come across anything just yet!

The problem I am trying to solve is this;

A user will will view a Property in my application and I want to be able to show them on the Home Page a list of the last 10 properties they viewed to make it easier for them to jump back into the property instead of having to search for it again.

The solution I have been working on is that when a User loads the page, the workflow will create a new data thing called “Page View” and updates the User with a list of Page Views.

On the Home Page there is then a repeating group which displays the logged in User’s last 10 page views.

The problem with that however is that every time the page loads it creates a new Page View and the same Property could appear several times in the list of last 10 Page Views on the home page.

So, I am essentially looking for a solution to filter out in the repeating group the last 10 Property’s visited rather than the last 10 Page Views.

I might be coming at this completely wrong, so any help or nudges in the right direction would be much appreciated.

Thanks

Hi there, @michael.edwards… after playing around with an example (and if I understand your post correctly), I would likely add a recently viewed properties field on the User data type, and that field would be a list that is tied to the Property data type. When a user views a property, you add the property to the user’s recently viewed properties list only when the list does not already contain the property. Finally, you show the user’s list in a repeating group, and you should be good to go.

Oh, and about showing only the last 10 properties the user has viewed, you could add a workflow step that removes a property from the list when a count of the items in the list is 11. That would be a better way to go than allowing the list to keep growing but only showing the most recent 10 items in the repeating group.

Any of that make sense and sound like it could work for you? Hope this helps.

Best…
Mike

Thanks @mikeloc, thats the structure I have set up, but the bit I am struggling with is the “only when” part of it, I can’t seem to get it working. Here is a screenshot of the workflow so far

Essentially, when the page is loaded the workflow creates a new Page View and then the next step adds the Page View created in step 2 to the User’s Page Views.

As you can hopefully see, I am attempting to use the Only When section to tell it to not add the Page View if the Property is already in the Page View list.

I suspect it is obvious, but I just can’t seem to get it working.

Any suggestions?

Thanks in advance!

I’m not sure why you need to create a new thing called a page view. You know what property the user clicked on and you are navigating to a page to show that property, right? So, can’t you just add the selected property to a list of properties on the User data type? What is the purpose of the page view data type?

Here is an example of the workflow step associated with selecting a property from a dropdown and then clicking a button that adds the property to the user’s list…

property

Having a list against the user of recently viewed properties was how I originally went about it, but the problem I couldn’t overcome there was sorting the list in anyway, but if I am only showing 10 that’s not the end of the world