Single select in table 1 = field name of table. GetCellValue from row 0 of this table.

1239 1
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

I want to use a single select that is submitted via a form to populate a field in this record called art_tone. 

This is Airtable automation.

Note: the aim of this was to use this approach for a few thousand variations so IF statements with No code would hit the 25 actions limit very quickly.

The input variables are the airtable record id = recordid. The other input variable is the field heading name we are looking for in the 'Name 1' table. This is named name1fieldname, the value of this input is from the field 'tag' from art1. I am only interested in the first record [0]. I want the cell value from the field with the value 'tag' pulled through from the input variable name1fieldname. 



// Access the record passed in from the automation
let inputConfig = input.config();

// Get the values from the record fields
let recordid = inputConfig.recordid; 
let parentingfieldname = inputConfig.parentingfieldname; // Input variable parentingfieldname

// Here's the main function:
async function main(params) {
    // Read the input parameters:
    let { parentingfieldname, recordid } = params;

    // Log the input parameters for debugging:
    console.log({ parentingfieldname, recordid });

    // Define your tables:
    let articlesTable = base.getTable('articles1');
    let parentingTable = base.getTable('parenting');

    // Get the record from the articlesTable:
    let record = await articlesTable.selectRecordsAsync().then(result => result.getRecord(recordid));

    // Get the parenting field value of the record:
    let parentingFieldValue = record.getCellValue(parentingfieldname);

    // Make sure the parentingFieldValue is not null or undefined:
    if(parentingFieldValue === null || parentingFieldValue === undefined) {
        throw new Error(`Field ${parentingfieldname} is not set for record ${recordid}`);

    // Fetch the first record from the parentingTable:
    let firstParentingRecord = await parentingTable.selectRecordsAsync().then(result => result.records[0]);

    // Get and log the fields of the parenting table:
    let parentingFields = parentingTable.fields;
    console.log("Fields in the parenting table: ", =>;

    // Check if parentingfieldname is a valid field in the parenting table:
    if(! => {
        throw new Error(`Field ${parentingfieldname} does not exist in the parenting table.`);

    // Get the field value for the parentingfieldname:
    let fieldValue = firstParentingRecord.getCellValue(parentingfieldname);

    // Log the fieldValue for debugging:
    console.log(`Field Value of ${parentingfieldname} : `, fieldValue);

    // Now we update the articlesTable's record:
    await articlesTable.updateRecordAsync(recordid, {
        "prompt_tone": fieldValue


I have checked to ensure the input variable parentingfieldname coming from 'articles1' are identical to the field names found in the table 'parenting'.

1 Reply 1

One thing is you never call your main function, however, wrapping everything in main here isn't necessary. Airtable wraps everything in an async function for you so you can use await at the top level.

It's difficult to follow your field names from the prompt and code as they seem to contradict. What fields/tables are you using? 
Table: articles1, field: prompt_tone (single line text)
Table: parenting, field: tag (single-select)
Is that correct?

Lastly, this use case can pretty easily be accomplished with Airtable's no-code automations.