Track user who clicked a button

I have a button that opens up a URL that acts as a webhook to an external application that runs a function.

In the querystring, I’d like to include either the userID or email of the user who clicked the button for accountability purposes. I don’t see an option for that in the default fields.

Is there any workaround for this? Can I do something to hack that user as the last modifier or something? Is it something that would be possible if I ran a script on button click instead? Script seems like overkill.

Welcome to the Airtable community!

Calculated fields, such as buttons and formulas, are not aware of the current user. However both scripting and custom apps can determine the current user.

A script can determine who the current user is. Your button would run a script, and the script would calculate the url, including the current user’s email as a query parameter. Then the script would output the link.

Or you could have the script call the webhook itself, without the user having to click the link.

I do not recommend using a last modified by field type, as the current user may not have actually modified anything before clicking the button.

If you do not code, but have budget to hire someone to write a script, feel free to book a meeting with me.

Another option would be to use either a checkbox or single select field as the trigger to drive an automation, which would run a script to determine the user and trigger the webhook as @kuovonne suggests. The benefit to this method is that the sidebar would stay closed for a slightly cleaner user experience. While it’s an extra click to use a single select field, I prefer that option over checkbox triggers partly because I can have different select options trigger different automations, plus the extra click prevents accidental triggers that can happen with checkboxes.

A script needs to use the session to determine the user, and the session is only available in scripting app, not in automations. Thus, an automation script cannot directly detect the user who triggered it. You would need to have a ‘last modified by’ field for the checkbox or single-select field driving the automation.

1 Like