Help

Using Scripting to By Pass Table Syncing

Topic Labels: Scripting extentions
3093 7
cancel
Showing results for 
Search instead for 
Did you mean: 
Drew_Nemer
8 - Airtable Astronomer
8 - Airtable Astronomer

I want to use scripting to go around AirTable restriction of syncing into one base and not being able to reflexively update the other.

The goal is that we have one person in the company that manages property owner data, and I am looking for a way to allow him to have his own space.

Right now the plan is to sync W9 submissions from one base to the Property Owner Data manager base upon entering a certain view.

In the other Base, the PO Data manager will be able to review the W9 submissions and put in an approval or denial with an attachment that would go back to the home base–updating the status.

I know that On2Air and other pay for services offer this. And i can always leverage emails. But I was wondering if perhaps by using a button column in the sync receive base that would ignite a script that would read into the original base, find the matching row and update it to show that it has been approved.

Is this possible?

Drew

7 Replies 7

Hi @Drew_Nemer
Yes, with the scripting block you can take advantage of the Airtable API to update records in another base this trigger can be added to a button field or you can use automation scripting to send just a single record’s details with input.config()

Is there anywhere I can find a tutorial on how to start that? this would be my first script.

First read up on the Airtable API, you can find specific details for your bases at: REST API - Airtable

Then you will need to POST using fetch() with javascript.

One thing to be aware of when doing this is that you will expose your API key to any user that has access to you base with the scripting block, internally this may not matter but if this is public you may want to visit other options.

make.com is a 3rd party tool that can monitor changes in Airtable and let you update one base from another without the API key exposure risk.

sounds like that is the plan, i think i need to learn more about scripting in general in order to make the best use of this because i am still lost. I must be too inexperienced

You can do it, I had never written any javascript before a few months ago. Here is an excerpt from a script I made that takes records from one table and inserts them into another table. This is set to run on a button field.

let table = base.getTable('req');
let record = await input.recordAsync('',table);
let body = {
        'records': [
            {
                'fields': {                  
                }
            }
        ]
    };
let response = await fetch(`https://api.airtable.com/v0/${baseID)/${tableID}`, {
  headers: {
    'Authorization': 'Bearer yourAPIKEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(body),
  method: 'POST',
});
output.text("Updated a record!");

That is hopeful! I am just very frustrated trying to figure out what exactly I should do to make the airtable functionality work the way i want to.

So does this script work to update existing records? like a bypass to the restrictions of multi-way base syncing?

This script in particular does not as it just creates a new row in the other base with select records from the scripting base. However there is nothing stopping you from updating a particular record. You will need to first get that record ID, then you can update following the instructions in the API documentation.

I should note, this is not an attempt to bypass syncing bases, that comes with its own set of features that are not mimicked here. This can be used in scenarios where you do not need all records synced, but still need to transfer a set of records to another base. The records are not synced for future changes.