How to Make Quick Base Form Rules for Specific Users
- July 14, 2017
- Posted by: Phillip Dennis
- Category: How-to for Quick Base Developers
Will the current Quick Base user please stand up?
As a Quick Base app builder, dynamic form rules help you to give your users an attractive and intuitive experience interacting with individual records. They also play an important role in maintaining data integrity and security. In particular, Quick Base allows you to make form rules conditional upon the user’s role:
It’s a useful tool to be able to show or hide certain fields or sections based on whether the user is in a role that would need to access that information on that particular form.
But every Quick Base developer is frustrated at one time or another by the fact that you can’t make rules for specific users, only for roles. Why can’t there be a “When the user is …” condition? Especially in a big and complicated app, setting up a special role just for one or two individuals can be time consuming and put data at risk if you forget to set appropriate table, field, and report role permissions, as well as to adapt any other role-based form rules for the role you just created.
Thankfully, there is a workaround to the frustrating absence of a “When the user’s identity is” condition: the User() and UserToName() functions.
Using Quick Base User() and UserToName() Functions
The solution is to create a formula text field with a simple formula to reveal the current user, whoever that happens to be at the time.
The User() function by itself doesn’t return a value that will be easy for you to use in a dynamic form rule. It returns the current user as a user data type. We’re going to use the Quick Base function UserToName() to convert the value returned by the User() function to a simple text value with the user’s name.
The UserToName() function takes one or two arguments depending on how you want the user’s name to be formatted: UserToName(user, format). If you use the formula without specifying a format, it will return the user’s full name, beginning with the first name. This is equivalent to passing a “FF” format argument (“first-name first”). On the other hand, if you pass a “LF” format argument (“last-name first”), it will return the user’s full name beginning with the last name.
Using the Field In a Form Rule
The next and last step is to use the formula text field we just created in our form rule. In the example above, I named the field User (perhaps I should have named it Current User or similar to avoid confusion). But in any event, I now create a condition based on the value in that User field, which will always give the full name of the current user in the form.
In this particular example, I want a different default value to appear in a field for myself than for everyone else. And now that we have a User() field in this table, we can add other form rules for specific users as required.