Filtering By Department

A common scenario is when you only want users to see what's in their department, and nothing else. One solution is to use the new multi-tenancy features, but if you don't want to go that route, you can just set up a regular filter permission. We'll discuss that now.

First off, you would store the user’s department in the record. So you’d first make sure you have a Department field in the User record, and set this up for each user after publishing. 

Next you’d:

1.    Add a field to your form called Department
2.    Set its Is Calculated to Yes
3.    Set its Calculation to: load(&root/Users[UserID=#input/_CreatedBy])/Department
(this looks up the user creating the record, and retrieves their department)

Now when you create a record, you should see the department copied over from the Users field.

Now you can add a role permission that filters based on the current user’s department. Add a permission under a role, with the Filter Field set to “Department” (the field you’re filtering on in the form) and the Expression set to “Department” (the field it will compare against in the User’s profile).

Now when you add that role to a user, they will only be able to see things created by users in the same department.

Note: To combine that filter with the Assigned XXX role, you will need to add a "vb" field tag to the field, so it should be Department:vb instead of just Department.


Next Topic:
v4.2.0.956 (beta)
Up Since 2/29/2024 12:02:23 AM