Force reload all collections used in a page

I know this has been asked in multiple other threads before but I haven’t found a satisfactory answer yet and I can’t accept that there’s just no way to do this.

The app I’m working on has a dropdown menu that basically lets the user switch between different profiles under the same account, via a global variable. Nearly all the data displayed in the app is dependent on what profile is currently active, only data associated with the current profile should be displayed. Hence, when the profile selector is used to switch profiles, ideally all collections should be re-fetched accordingly. At the very least, all collections used on the current page.

I have tried using JS to reload the entire page, to no avail (profile selector resets to the profile that was active before the profile change).

The next suggestion I’ve seen that I’m in the process of implementing is using a workflow with branching logic to fetch specific collections based on the current page. This should work in theory but my app has 30+ pages so setting this up is incredibly tedious, not to mention the extensibility & maintainability issues. Also several collections are filtered based on other collections which means I have to think through the order things need to load in for everything to work correctly. Again, tedious and fragile. Side note: WeWeb really needs a way to leave comments in workflows, etc.

Surely there is a programmatic way to determine what collections are in use on a given page, and what the dependencies are such that they can be automatically re-fetched in the correct order. I really think this should be available as a workflow action but in the meantime I would be very grateful if someone could point me in the right direction to get this done in JS. I have tried looking through the wwLib methods in my browser devtools console but am not getting anywhere with that.

Thank you!

GD

1 Like

Great question, let me check with the team and get back to you ASAP with a possible solution or resource that can help you.

The most straightforward way would be (if you don’t mind refreshing the page) to

  1. Store the “selected profile” variable so that it is Preserved on navigation
  2. Do your refresh

This way, when you load the page, you still have your variable stored and you can use it (bind it to fetch/filter the collection - hit the API or whatever).

Unless something has changed, WeWeb fetches all the collections that are used in the current page. Meaning that if you have a text bound to that variable, and you have the fetch collection automatically ON, it should in theory be fetching the data on page load, if it’s used somehow in the page, without the need for you to trigger any fetches.