What I’m trying to do:
I am trying to create an Anvil app that contains computer asset information for organizations, each organization will have it’s own “Assets” page that tracks the assets belonging to that company. Each company should only have access to their own data and be able to add/edit/delete assets for their own company.
I am pretty new to Anvil, I just finished the “Creating a database-backed app” and the News App tutorials, and I understand the contept of creating data tables and displaying them. I am wondering what the most efficient way to create the pages are, is it possible to have multiple “Asset” pages that are generated for each organization that gets created in my app so they have their own page? I created a data grid on one page that displays all of the companies and the company details, there is also an “Add Organization” feature. I am now trying to create the “OrganizationView” page that shows the assets belonging to the organization.
Here is a copy of my current app: Anvil | Login
Any advice or tips would be appreciated for my first Anvil app.
Anvil’s a great choice for the type of app you’re describing.
You’ll have a single Assets form, but as part of of loading data for that form you’ll limit it to just the Organization whose data you want to show when you query the data tables. So think not in terms of a page for each Organization, but just changing the filter in the query so you’re only fetching the data for the one Organization.
@jshaffstall Thank you for your response. I think I get what you’re saying. So for example, on the page where I would list the assets for an organization, I would have a “get assets” function that would display the assets for a given organization. Is there a way that each user of my app that signs app can only access their own tables?
Yes, that depends largely on your data table design. This may not apply to your app, but a general approach would be for each user to link to the organization they are part of. Knowing the organization you could then query the assets for that organization.
For example, assume that you have an Assets table, with a row describing each Asset. The Assets table could have a column, Organization. In any given row, the row’s Organization value would identify which Organization owns that row’s Asset.
You would then filter on that column, so that only the corresponding rows (for the current Organization) would be accessible.
Anvil has direct support for such filters. See Views.