Scenario
You want users to be assigned to individual records. Records assigned (connected) to a user can then be made viewable only to that user.
Users can also be assigned to user roles. Those roles can then be used to specify what information and functionality users have access to.
A common example of assignments is task management, where supervisors assign tasks to employees. Each needs to perform different actions and view different sets of information.
Requirements
You'll need to activate users in your app. You'll also need to set the user settings to have logins for different pages and user roles. This article will show you how: About Users.
If this is your first time creating an app, you'll need to know some basics about adding objects, fields, pages, and views. You can start by watching our "Introducing Knack" video tour and then working through the articles in our Get Started section.
Steps
In this example, you will be creating a workflow for staff to assign tasks to employees and for employees to view their assigned tasks.
Create the User Roles
In the Data section of the builder, create two user roles:
- Staff
- Employees
Create a Tasks Object & Connect It to Employees
Create an object to store all your tasks.
For this example, you'll need the following fields:
- The default "Task Name" field (which is automatically added)
- A date/time field called "Due Date"
- A multiple choice field called "Status" with the following options:
- In Progress (make this the default option)
- Completed
- A one-to-many connection field to the Employees object called "Employee"
- The connection field will allow you to assign each task to one employee and to assign multiple tasks to each employee.
Create a Staff Page
In the Pages section of the builder, create a new page that allows only Staff users to access it. Then select the Tasks object and add a table view that includes:
- A link to view more details on each task
- A form for editing each task
Call the page "Assign Tasks":
Make it Easy for Staff to Assign Tasks
Now you're going to make some changes to help make it easier for Staff users to assign tasks.
Display Only Unassigned Tasks
Since the Assign Tasks page is for assigning tasks, you're going to display only tasks that are unassigned.
1. Click on the Tasks table view on your new Staff page to edit it.
2. Go to the Data Source section.
3. In Data, add a rule for only displaying tasks that don't have an Employee connected (assigned):
- "Employee" is blank
Rename Edit Tasks Link
On the Assign Tasks page, your Tasks table currently has a column called "Edit Task" with a link to the form for editing the task. We want to make it clear where Staff users need to click to assign a task.
You can check the box next to Preview in the builder to see what your views would look like in the live app:
To make it clear for Staff users, you're going to rename the Edit Tasks column.
1. Click on the Tasks table view to edit it.
2. Hover over the Edit Task column and click the pencil icon to edit the column.
3. Rename the Column Header to "Assign Tasks" and the Link Text to "Select Employee":
Prepare Form to Assign Tasks
The form on the Edit Task page currently includes all fields in the Tasks object. However, you only want Staff to assign employees to a task in that form so you're going to update that form.
1. On the Edit Task page, click on the form view to edit it.
2. Change the title of the form to "Assign Task."
3. Remove all fields except the Employee field:
Make Form Appear in Modal Pop Up
To access the form for assigning a task, users are currently being redirected to the Edit Task page with the form. But if users need to assign multiple tasks, it can take time to go back and forth between pages. Instead, you can have the form appear in a modal pop up on the Assign Tasks page.
1. On the Edit Task page, go to the Settings tab.
2. Check the box next to "Display page in a modal popup":
Create an Employees Page
In the Pages section of the builder, create a new page. Enable login and restrict access to the Employee user role. Then select the Tasks object connected to the logged-in Employee and add a table view that includes:
- A link to view more details on each task
- A form for editing each task
Call the page "My Tasks":
Make it Easy for Employees to Complete Tasks
Now you're going to make some changes to help make it easier for Employee users to mark tasks as complete.
Rename Edit Tasks Link
On the My Tasks page, your Tasks table currently has a column called "Edit Task" with a link to the form for editing the task. We want to use this form to allow Employees to mark a task as complete.
You can check the box next to Preview in the builder to see what your views would look like in the live app:
To make it clear to Employee users, you're going to rename the Edit Tasks column.
1. Click on the Tasks table view to edit it.
2. Hover over the Edit Task column and click the pencil icon to edit the column.
3. Rename the Column Header to "Mark As Complete" and the Link Text to "Complete Task":
Prepare Form to Complete Tasks
The form on the Edit Task page currently includes all fields in the Tasks object. However, you only want Employees to mark a task as complete so you're going to update that form.
1. On the Edit Task page, click on the form view to edit it.
2. Change the title of the form to "Mark Task as Completed."
3. Remove all the fields:
Finally, since there are no fields on the form, you're going to use a record rule to automatically set the task to complete.
4. Go to the Form Rules section
5. Click on the Record Rules tab.
6. Add the following record rule:
- Action: Update this record (the default option)
- When: Every form submission. (the default option)
- Values: Set "Status" to a custom value "Completed"
Make Form Appear in Modal Popup
To access the form for assigning a task, users are currently being redirected to the Edit Task page with the form. But if users need to assign multiple tasks, it can take time to go back and forth between pages. Instead, you can have the form appear in a modal pop up on the Assign Tasks page.
1. On the Edit Task page, go to the Settings tab.
2. Check the box next to "Display page in a modal popup":
Your Results
Here's how your app will look now:
Extend This Workflow
- Use inline editing to assign multiple tasks from one place
- Send email notifications to employees who have been assigned a task
- Send email notifications to staff about completed tasks
- Add status indicators for staff or employees reviewing open vs completed assignments
- Add filter menus to the tasks tables for staff or employees reviewing open vs completed assignments
- Send reminder emails based on due dates for assignments