- 28 Sep 2022
- 3 Minutes to read
Scripting extension overview
- Updated on 28 Sep 2022
- 3 Minutes to read
The scripting extension can streamline your workflows when you want to modify field information, add multiple records at once, filter with complex criteria, and more. With the introduction of script templates, any user - even without technical knowledge - will be able to leverage the power of the Scripting Extension by installing pre-built scripts from our extensions marketplace created by Airtable and members of Airtable’s growing community.
Adding a script from the extensions marketplace
You can now install pre-built scripts from our extensions marketplace. Start by visiting the scripts section of the marketplace and browsing through the available script templates.
When you find one you'd like to install, click the "Install" button. You'll then be given an option for which base you'd like to install the script on.
Add your own custom script
To get started with developing your own custom script, view our developer documentation here.
Getting started with the scripting extension
Once you have added the scripting extension to a dashboard in your base, the extension will open up in edit mode with three panes. If you are not able to add the scripting extension, your organization may have restricted the use of the scripting extension for your account.
Any user can press the "run" button in a scripting extension, however, the scripting extension respects the permission level of the user running the script. For example, if a certain line of code were to "update a record" or "create a record", then the user running the script would need to have corresponding permission levels, in this case, creator-level permissions, in order to successfully run the script. If the user does not have those permissions, then the scripting extension will throw an error code.
Running a script
To run a script, click the "Run" button in the right-hand results pane. If you need to stop the executing script at any time, you can click the red "Stop" button in the upper right. Once the script is complete, you have the option to run it again using the "Run" button.
Using script settings, you can enable an interactive UI to make your script more user-friendly and easily customizable. Rather than hard-coding table names or field names, you can add an interactive UI to configure settings for the script.
To get started with script settings, add a call to input.config() at the beginning of your script, and follow the in-app documentation (under API -> Script Settings) in the scripting extension code editor. You can also access the documentation and see more examples here.
As you update your code in input.config(), the UI in the right-hand pane will update accordingly. Settings can be defined for tables, fields, views, text, numbers, and select options. After the settings have been configured in the interactive UI, the object returned from input.config() will contain the actual models for these items that can be referenced later in your code. When running a script with script settings enabled, the settings panel needs to be fully populated before the "Run" button is enabled.
After settings are configured from the UI, the values chosen will persist between runs, and are shared between all collaborators. To re-configure the script settings, simply click the settings icon:
How can I trigger a script automatically?
As of now, the scripting extension executes when you click the run button. If you're interested in writing a script that will run on a certain trigger, check out the Run a script action.
I need a bigger screen for my code.
Minimize the in-app docs by clicking the down arrow.
Can single-select or multi-select field option names and/or colors be updated with a script?
Yes, the scripting extension (note, this is ONLY available in the scripting extension, not in Automations nor via the REST API) includes a method
.updateOptionsAsync() that can be used to update the names and colors of select options. You can learn more about the method here and how to do it for specific field types (like single select) here.