Aug 15, 2023 04:26 PM
Hello Airtable Team.
I am trying to run the following script, but it show me this error:
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.
Solved! Go to Solution.
Aug 16, 2023 08:09 AM
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.
Aug 16, 2023 08:09 AM
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.
Aug 16, 2023 08:21 AM - edited Aug 16, 2023 08:21 AM
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.
Aug 16, 2023 09:11 AM
Here's what you can do:
Use Airtable Automations: Instead of trying to watch for changes in the scripting app, set up an Automation directly within Airtable's interface:
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.