Displaying Records Shared Within User Groups
Set up group-based record sharing in Knack so multiple users within the same company, division, or team can view the same set of shared records.
What You'll Learn
- How to connect users to groups
- How to set up records shared within groups
- How to create elements that respect group-based access
Overview
This guide demonstrates how to create group-based record sharing in your Knack app. Unlike showing records connected directly to a logged-in user, this approach allows multiple users within the same group (like a company division) to access the same set of shared records.
Builds on user connection conceptsThis article builds on concepts from displaying records connected to the logged-in user. Review that topic first if you're unfamiliar with user connections.
Prerequisites
- Users must be enabled in your app
- Understanding of table connections
- Basic knowledge of page creation
Step 1: Creating Tables and Connections
In this example, we'll work with three elements: a Sales Rep user role, a Division table, and a Sales Leads table.
Setting Up the Connection Structure
First, connect Sales Reps to Divisions:
- Select the Sales Rep user role table.
- Click the + button to add a new field.
- Choose Connection.
- Select the Division table as the connection target.
- Choose Connect to one Division (one-to-many relationship).
Next, connect Sales Leads to Divisions:
- Select the Sales Leads table.
- Add a Connection field.
- Connect to the Division table.
- Choose Connect to one Division (one-to-many relationship).
These connections create a shared relationship: each Sales Rep belongs to one Division, each Sales Lead belongs to one Division, and a Division can have many Sales Reps and many Sales Leads.
Step 2: Updating Records
Assign divisions to your existing records:
- Navigate to the Sales Rep user role.
- Select the Records tab.
- Edit each record to assign the appropriate Division.
Repeat the process for Sales Leads:
- Navigate to the Sales Leads table.
- Select the Records tab.
- Assign the appropriate Division to each lead.
Step 3: Creating Restricted Access Pages
Create a page that will show only the leads from the user's division:
- Go to the Pages section of the Builder.
- Click the + button to add a new page.
- Select Login Page.
- Restrict access to the Sales Rep user role.
Step 4: Adding a Filtered Element
- Add a Table or List element to display Sales Leads.
- In the Source options, select Sales Leads.
- Under Filter, choose: Sales Leads > Division is Division connected to the logged-in user.
This filter is the key to group-based access. It ensures users only see leads that belong to the same division they're connected to.
Step 5: Testing Your Configuration
- Click Preview or Go to Live App in the Builder.
- Log in as a Sales Rep.
- Navigate to your new page.
- Verify that only leads from the user's division are visible.
Troubleshooting
Common Issues
Too many records showing: Check that your divisions are properly assigned to both users and records.
No records showing: Verify that the filter is correctly set to "Division connected to the logged-in user."
Access problems: Ensure the page is properly restricted to the Sales Rep user role.
Adding Elements to Existing Pages
If you already have login pages set up:
- Navigate to the page in the Builder.
- Click Add Element.
- Follow the same steps to configure the filtered element.
Works for any group structureThis same approach can be used for any group-based sharing scenario, such as departments, teams, companies, or locations.
Next Steps
- Adding Read-Only Access For Users for view-only record access
- How to Manage User Role Access for controlling page-level permissions
Updated 10 days ago
