Help

Permissions on a button

Solved
Jump to Solution
2185 7
cancel
Showing results for 
Search instead for 
Did you mean: 
Sharon_Visser
7 - App Architect
7 - App Architect

Hi Airtable Community,

With sample scripts that I found here, I was able to create a script to duplicate a record, and I’ve set up the script to run on a button. [So, thank you for all those how-to scripting posts!!]

However, I was hoping to be able to limit access to the button, so that only the right people could click and run the script. But, on the button field the option to set “Edit field permissions” is grayed out. I know I can hide the button from certain views, but my users do know how to copy a locked view and hide/show whatever fields they want in their personal or collaborative view.

Is there another way to prohibit who can click a button, since field-level permissions are not an option?

Thanks for any help provided.

1 Solution

Accepted Solutions
Rupert_Hoffsch1
10 - Mercury
10 - Mercury

Hi @Sharon_Visser, there is no way currently to prevent a button from getting clicked. So if you have a button in your table, users are able to click it.

The solution for this would be to not use a button, but a checkbox which triggers an automation with the script. It’s possible to set field permissions on a checkbox.

I can help you change the script accordingly if you post it here (shouldn’t be too much of a big deal).

Cheers,
Rupert

See Solution in Thread

7 Replies 7
Rupert_Hoffsch1
10 - Mercury
10 - Mercury

Hi @Sharon_Visser, there is no way currently to prevent a button from getting clicked. So if you have a button in your table, users are able to click it.

The solution for this would be to not use a button, but a checkbox which triggers an automation with the script. It’s possible to set field permissions on a checkbox.

I can help you change the script accordingly if you post it here (shouldn’t be too much of a big deal).

Cheers,
Rupert

ScottWorld
18 - Pluto
18 - Pluto

@Sharon_Visser:

One thing to note is that you don't need to use scripting at all for this. See below for more information on this.

But first: @Rupert_Hoffschmidt’s suggestion is the easiest & best solution to implement, and it is the one that I would recommend for you as well. 

However, I would recommend using a single-select field instead of a checkbox field. You can read more about this technique in this thread.

So using a field instead of a button is the best way to tackle this.

However, if you'd still like to use a button, you can still do this, too! 🙂

There is one hidden trick to prevent a button from getting clicked in Airtable, and that is to make it a button that opens a URL.

You would create a URL formula that results in NOTHING under the circumstances that you don’t want the button to be clicked. This will dim the button and make it unclickable in Airtable!

Under the circumstances that you DO want the button clicked, you would need to have your formula result in a URL that triggers a custom webhook using Make's automations & integrations.

Once your Make webhook is triggered, you would have Make perform the entire automation for you there, with no scripting necessary at all. You would simply use Make's Airtable automations & integrations.

So, to summarize: just send the request to Make, and process the entire automation there. No scripting necessary.

I demonstrate this entire technique through the context of an email (instead of a button) on this Airtable podcast episode. But the exact same technique could be applied to an Airtable button as well. Check out my demonstration, and you will see how easy this is to setup: https://youtu.be/58urboTLZck?list=PLqssva4liHRwHhQIpTXekG8WObEoyC2F1

The reason that you would have to use Make instead of Airtable to process this request is because Airtable’s incoming webhooks don’t support GET requests (i.e. URLs). There is no way around this requirement at this point in time.

(Of course, if you really wanted to run a custom Javascript in Airtable, you could always have Make send back a POST request to an incoming Airtable webhook using Make's HTTP tool.)

p.s. If your company has a budget for your project and you’d like to hire an expert Airtable consultant to help you with any of this, please feel free to contact me through my website: Airtable consulting — ScottWorld

Actually I thought about it again with inspiration from @ScottWorld 's reply… there is a way of making it happen with a button and the consequentially triggered script: You could change the script in a way that it only does what it does (duplicate records) IF it is triggered by a certain user. The current user you get via Session: Airtable Scripting — Session.

Ah, the workarounds we have to come up with to fight Airtable’s limitations — haha! Let me know if you want help with that!

Thank you @Rupert_Hoffschmidt for the idea! The checkbox actually solves 2 problems: 1) field permissions, and 2) a checkbox can be used on an Interface, while a button cannot. I try to use Interfaces as much as possible for my users.

I would also like to learn how to use the current user variable - I think I get it from the link you posted.

Thanks, @ScottWorld for this suggestion. It has a lot more moving parts, and I’m trying to do everything within Airtable and not have to purchase other products, at least until I run into a problem that can’t be solved any other way. This certainly adds to my learning!

Always happy to help when you’ve got questions!

Something to keep in mind is that the script runs in the context of the permissions of the active user. If the user does not have the permissions to edit a field or create a record, the script will not be able to do those things. The script will only change data that the user could change manually without the script.