Help

Re: In scripting, is there a way to access a different base than the one that you are in?

4159 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Olivia_Ehrenrei
5 - Automation Enthusiast
5 - Automation Enthusiast

I’m using a custom script to get records form the base I am in. To do this, I am using using:

base.getTable('Incoming');

Now, I’d like to create new records using data from the records in base.getTable('Incoming') in a table that lives in a different base. How can I reference a different base from this script?

10 Replies 10

Scripting is only aware of its own base. If you want to use scripting to access a different base, you can use the REST API. However, you would not be able to take advantage of any libraries, and you are exposing your API key to all users in the base.

Another option would be to use a script to call a webhook automation in the remote base. Then have script in the remote base create the record.

Is there a way to use the API inside of a script? Also, when you mention webhooks, does that mean integrating with another software?

Using the REST API from a script is just like using the REST API from anywhere else, except that you cannot use libraries. See the documentation for more info.

The webhook automation is documented here

Olivia_Ehrenrei
5 - Automation Enthusiast
5 - Automation Enthusiast

I guess I’m wondering how to access the below (from API docs) in the scripting:

var Airtable = require('airtable');
var base = new Airtable({apiKey: 'YOUR_API_KEY'}).base('appLeAWrWWE5ctwux');

How can I use the API in a script if I don’t have access to the base I want to send to/from?

Does the script “know” about require('airtable');?

When you use require('airtable') you are trying to include a library. This will not work. Scripting cannot use libraries. You will need craft the API calls on your own. Depending on your level of coding experience, this might be a large learning curve, or (if you have budget) you may want to hire someone to write this for you.

Why do you want to create new records in a different base? Could you use a synced table instead?

Olivia_Ehrenrei
5 - Automation Enthusiast
5 - Automation Enthusiast

I think I can craft them on my own, but I’m still unsure of how to reference the base in the scripting app? Would I have to create a custom React app to do this?

Also, I just saw the “sync table” feature:
Screen Shot 2022-01-28 at 2.32.21 PM

Is there a way to do this programmatically?

The issue is that we want to make space in one base by moving or deleting records we don’t need everyday but want to hold on to.

You would not create a react app. That is for creating a custom app, not using the REST API. The documentation for the REST API is quite good and has all the information that an experienced developer needs.

Yes, that is the synced table feature that I referred to in my earlier post.

Olivia_Ehrenrei
5 - Automation Enthusiast
5 - Automation Enthusiast

But how can I use the API in the script if I can’t use libraries? Where should I use the API?

You must build every aspect of the API call without the benefit of helper libraries (i.e., SDKs). It’s very tedious and it places all the integration burden on you and requires a deep understanding of native javascript directives. Don’t do this if there’s a better way, and @kuovonne has already pointed you in that direction - calling an Airtable webhook seems far less complex and requires no API key exposure or API skills.