Forum Discussion
Interestingly enough, I recently had a kinda similar use case. I typically try to stick with the auto-incrementing primary keys instead of altering the key field (e.g. to a User) for reasons I won't explain here. Anyway, it sounds like you could potentially leverage your existing Employees table in combination with Formula Queries and (conditional) Formula URL buttons to create a "Person Locator Service" or "Person Authorization Service." For example,
// _DBID_EMPLOYEES
// FID 3: Record ID# (Integer)
// FID 999: Quickbase User (User)
// FID 9999: Quickbase User Has xyz Permission (Checkbox)
// Return the Current User's Record ID
var Text QueryResults = ToText(GetFieldValues(GetRecords("{999.TV.'" & UserToId(User()) & "'}", [_DBID_EMPLOYEES]), 3));
ToNumber($QueryResults)
Instead of returning the Current User's Record ID (3 in the above example), you'd could return a boolean of whether the Employee has access to perform the given operation (e.g. Add the record). Maybe something like:
var Bool HasPermission = ToText(GetFieldValues(GetRecords("{999.TV.'" & UserToId(User()) & "'}", [_DBID_EMPLOYEES]), 9999));
Then, in a Formula URL (button) you can conditionally show or hide the button based on the results of the Formula Query.
var Text UrlAddRecord =
// Show form to create a new record
URLRoot() & "db/" & [_DBID_THINGS] & "?a=API_GenAddRecordForm"
// Set field value
& "&_fid_xyz=" & URLEncode ([…])
// Return to the context where this button was clicked
& "&z=" & Rurl();
If (
// Conditionally display this button
$HasPermission = true, $UrlAddRecord,
// Default to hidden button
null
)
I'm not saying any of this is a good idea, but it is interesting and sort of allows us to extend basic User info similar to a User Profile in other web apps. I'd consider building a playground Quickbase app to test the ideas before integrating it into your production app.
The simpler version of all this would be to hardcode the allowable list of Users into a variable and then conditionally show the button if the current User is in the list.
Use care with Formula Queries too, especially because they likely cause n + 1 query issues that I don't recall reading about yet!
I'd also suggest really digging into why Quickbase's native Permission system doesn't accomplish what you are hoping to achieve.
------------------------------
Brian Seymour
------------------------------
- MikeTamoush2 years agoQrew Commander
Thanks for the reply. I am in fact deciding to do something similar to this. The sticking point really is this - I would love to have that conditionally shown button on home page or dashboard. That is really only possible if you sneakily do it by showing a report with 1 record on it. This works, but is not super clean looking. That is why I was originally hoping to actually limit who could add, so that if they clicked the button on the home page, it would say 'permission denied'.
Though, it may be possible to make a custom button......I gotta play around with a few things. Ill report back if some ideas in my head work out.
------------------------------
Mike Tamoush
------------------------------- TylerJablonski12 years agoQrew Trainee
One option is to have a button on the home page that points to a code page. The code page can use the API to return the current user (API_GetUserInfo). Then you can query the users table for that user and check whether or not they have permission. If they do, you redirect them to the add form, otherwise you show them a "permission denied" message. Of course, this doesn't solve the problem of conditionally showing the button on the home page.
Another slightly more complicated option is that you have two home pages set up. One for users who have access to add records, which will have the add record button, and one for everyone else that doesn't have the button. Then in the user roles, you set the home page for everyone to a code page. The code page uses the API to check the user's permission as in the first option, and then depending on whether or not they have access, it redirects them to one of the two "real" home pages. That would solve the problem of conditionally showing the button.
------------------------------
Tyler Jablonski
------------------------------- MikeTamoush2 years agoQrew Commander
Tyler,
The code page is probably a good idea. Unfortunately, im a low code no code user so the code pages are past my knowledge. All I can do is take a pre-existing page and modify it for my own use. Don't suppose you have a sample of this type of thing? :)
------------------------------
Mike Tamoush
------------------------------