Groups and permissions

Summary: Learning how to work with groups and permissions.

In this section, we’ll cover how to set up permissions in your Slingr app. We’ll create a new field for tasks to identify the user assigned to each task. Additionally, we’ll create two groups: Manager and Support. The users in the Manager group will have access to all tasks, while the users in the Support group will only be able to see tasks assigned to them and won’t be able to reassign tasks or change the task title.

Create the field “Assignee” on tasks

To start, let’s create the new field for tasks:

  1. Right-click on the node Model > Entities > Tasks > Fields, and select New Field from the dropdown menu.

  2. Fill in the form with the following details:

  • Label: Assignee
  • Name: assignee
  • Type: Relationship
  • Related entity: System > Users
  1. Click on Create and Edit.

  2. Set the Default value to Script.

  3. Complete the field Script.

return sys.context.getCurrentUserRecord();

  1. Save the changes.

Create “Managers” group

Now letโ€™s add the two new groups:

  1. Click the node Security > Groups.

  2. Click on the Create button on the top-right of the page.

  3. Fill in the form with:

  • Label: Manager
  • Name: manager
  1. Click on Create and Edit.

  2. Now we need to add permissions to access entities and views. Click on the node Security > Groups > Manager > Entity permissions.

  3. Select the Task entity and then click on Apply permissions:

Apply permissions

  1. There select the option Read/write and click on Apply.

  2. Then click on the configuration button under the Edit column, and configure fields permissions so fields Status and Rank are read-only.

Field permissions

This is the correct way to enforce permissions instead of just making the field read-only in the UI.
  1. Now, select the System > Users entity and then click on Apply permissions, and this time select Read-Only.

  2. Finally, click the Apply button on the top-right of the listing to persist changes.

  3. Click on the node Security > Groups > Manager > View permissions.

  4. Set the flag in the column Permission for both views:

View permissions

  1. Finally, click the Apply button on the top-right of the listing to persist changes.

Create a “Support” group

Now that we have our first group, create a new group called Support, and add some permissions to it:

  1. Click on the node Security > Groups > Support > Entity permissions.

  2. In the Tasks entity, click on the configuration button under the Edit column.

  3. Configure entity permissions like this:

Entity permissions

  1. Configure field permissions like this:

Field permissions

  1. Configure action permissions like this:

Action permissions

  1. Click on Apply.

  2. Now, select the System > Users entity, click on Apply permissions, and select Read-Only.

  3. Save changes by clicking on Apply.

  4. Configure view permissions in Security > Groups > Support > View permissions in the same way as for managers.

Now that we have created the groups and defined their permissions, let’s push the changes so we can use these groups when creating users.


Create different users

It’s time to create a few users (make sure you have pushed the changes before):

  1. Click on the node Security > Users.

  2. Click on the Create button at the top right of the page.

  3. Fill in the form with:

  • First name: Manager1
  • Last name: Test
  • Email: manager1@test.com
  • Generate Password: true
  • Groups: Add the Manager group as Primary
  1. Click on Create to save the user.

Then repeat the same process for these users:

First nameLast nameEmailPrimary group
Support1Testsupport1@test.comSupport
Support2Testsupport2@test.comSupport

You don't need to push changes when working with users because users are modified directly in the runtime as they aren't part of the metadata of the app.

๐Ÿ˜Š

Awesome! We have finished this section and are almost done with our app.

In the next section, we will learn how to work with different users in the runtime.