Help

Save the date! Join us on October 16 for our Product Ops launch event. Register here.

watch is not a function.

Topic Labels: Automations
Solved
Jump to Solution
977 3
cancel
Showing results for 
Search instead for 
Did you mean: 
geocarlos
4 - Data Explorer
4 - Data Explorer

Hello Airtable Team.
I am trying to run the following script, but it show me this error:

ERROR

TypeError: trackerSsot.watch is not a function
    at main on line 7

Script:

// Define the table and field names

const tagsPods = base.getTable('TAGS TSM PODS');

const trackerSsot = base.getTable('Team Tracker SSOT');

const fieldToFill = tagsPods.getField('FULL NAME')

// Listen for new records created in the trackerSsot

trackerSsot.watch('recordCreated', async (event) => {

    const newRecord = event.record;

// Get the value from the new record in the trackerSsot

 const valueToFill = newRecord.getCellValue('FULL NAME')  

// Create a new record in tagsPods and fill in the desired field

 await tagsPods.createRecordAsync({

     'FULL NAME':valueToFill

 });

});

I appreaciate if you can help me to solve it. thank you in advance.

1 Solution

Accepted Solutions
Ron_Williams
6 - Interface Innovator
6 - Interface Innovator

If you are trying to do this in airtable automations there is no watch feature. You can, however, trigger the automation to start when a new record is created, and then create a new record in the other table without using any scripting if you wanted to. 

See Solution in Thread

3 Replies 3
Ron_Williams
6 - Interface Innovator
6 - Interface Innovator

If you are trying to do this in airtable automations there is no watch feature. You can, however, trigger the automation to start when a new record is created, and then create a new record in the other table without using any scripting if you wanted to. 

geocarlos
4 - Data Explorer
4 - Data Explorer

Thank you for the answer, Indeed that was what I did, but I would like to know, how to do this through a script.
I would like to improve my skills in javascript for both, Google Apps Script and Airtable.

Ron_Williams
6 - Interface Innovator
6 - Interface Innovator

@geocarlos 

Here's what you can do:

  1. Use Airtable Automations: Instead of trying to watch for changes in the scripting app, set up an Automation directly within Airtable's interface:

    • Choose the trigger as "When a record is created" in the "Team Tracker SSOT" table.
    • Then, for the action, you can choose "Run a script" and use a script that creates the record in the "TAGS TSM PODS" table.
  2. Script: For the script action in Airtable automation, it would look something like:

// Get input data from the trigger (the created record in Team Tracker SSOT)
let inputRecord = input.config();

// Define the table where we want to create a new record
const tagsPods = base.getTable('TAGS TSM PODS');

// Extract the FULL NAME value from the triggered record
const valueToFill = inputRecord.getCellValue('FULL NAME');

// Create a new record in the TAGS TSM PODS table
await tagsPods.createRecordAsync({
'FULL NAME': valueToFill
});

When you set up the script in the automation action, make sure to pass the triggered record (record ID as inputRecord value from "Team Tracker SSOT" in this case) as an input to the script so it can access its values.

ChatGPT can be invaluable when learning javascript for Google Apps Script and Airtable. Not that it's always correct but it can usually point you in the right direction.