Forum Discussion
- QuickBaseCoachDQrew CaptainThe formula for a formula user field for the current user is just
User()
So maybe that is all you need and not API calls.
As for making a formula URL button, I can help you with that. Do you just want to click a button and write the current user to a field and refresh the record? - ForrestParkerQrew CadetUltimately I want to add a user to an app through a formula url button. The api for that is API_AddUserToRole. This requires the UserID which is not accessible through a formula function; at least that I am aware of.
- PatrickDunnQrew Assistant CaptainForrest, I'm after the exact same thing. Did you ever find a solution?
- QuickBaseCoachDQrew CaptainTry using the the email address.
- PatrickDunnQrew Assistant CaptainUsing email in place of userid in the API_AddUserToRole call returns an invalid input error message. I can't figure out how to capture the userID via API_GetUserInfo and then pass that into a API_AddUsertoRole call. Thoughts?
- AlexWilkinsonQrew Assistant CaptainThe solution might simply be to have a User field (suppose it's called "This User") in a form rule like this:
When "This User" is ____ (empty or some other condition)
Change "This User" to the current user (that's one of the standard options for this type of rule)
... oh, just saw your comment about API_AddUserToRole ... so then you have User A adding or editing a record from which they can add User B to the app in some role, is that right?
I'll assume yes, and further assume that somewhere, probably in a different app in your Quick Base realm, User B exist (i.e., has an active, valid Quick Base login with a known email address). Let's says that it's in a table called "All Users" in an app called "My Directory".
Then you could ...
1. Populate a "UserID" field on every record in the "All Users" table -- by downloading from the standard User table in your app(s), extracting the IDs from that download, then uploading it into the "UserID" field. Maybe you do this with manual downloads and uploads via spreadsheets or maybe with API calls to API_GetUserInfo. Either way, the desired result is your own master table of Users and their IDs, names, and emails, with email as the key field in this master table.
2. In the app where you want to add the user in a role, create a cross-app relationship to the "All Users" table in your "My Directory" app. Call it "New User Email" and place it on the form to get User A (the one who's editing or adding the record) to identify User B. The parent in the cross app relationship is the email key in the the "All Users" table of the "My Directory" app. Create "UserID Lookup" as a lookup field on the relationship. User A will populate the "New User Email" field with an email, and, if that email exists in the "All Users" table, then the known user's Quick Base ID visible to the app where you are adding that user in a role.
3. When "New User Email" is filled and "UserID Lookup" is not null (i.e., User A is trying to add User B and User B is a known user in the "All Users" table of the "My Directory" app), then your button can use API_AddUserToRole.
4. Your button formula (or a form rule) should probably hide the button when "UserID Lookup" is null. - matthewperiutQrew Member
To retrieve User ID in a formula it would be UserToId(User())