Help

Re: Example Script for Automations Mark Duplicates

Solved
Jump to Solution
766 3
cancel
Showing results for 
Search instead for 
Did you mean: 
Sharon_Phelps
4 - Data Explorer
4 - Data Explorer

I’m trying to us the example script, and keep getting:
airtable recordid should be a string, not undefined
I am using the script as is, except I changed the table name on line 2.
I followed instructions on how to configure input variables using the left panel.
I added recordID field to my table, using the recordID function in formula field. When that didn’t work, I changed to a short text field, preserving the generated record ID values, but I still got this error. I’m out of ideas. Can someone help?

“TypeError: Invalid arguments passed to recordQueryResult.getRecord(recordId):
• recordId should be a string, not undefined”

TIA,
Sharon

1 Solution

Accepted Solutions

Make sure the capitalization of the input variable matches what you’ve typed in the script, and try pulling the record ID directly and not from a calculated field value

See Solution in Thread

6 Replies 6

Do you actually have a variable in your script called recordId? I can’t really help diagnose what’s wrong without actually seeing the script in question.

Thank you!
I am using the example script - the only thing I changed in the table name in line 2. I made some changes to my table to add and rename the fields, with the names used in the script “Duplicate to” and “recordID”. Here is the code:

// the table to check

let table = base.getTable(“Form View Table”);

// the record we’re searching for duplicates of.

// we need to create a ‘recordId’ input variable connected to a record trigger

let config = input.config();

let recordId = config.recordId;

// the field to save duplicates in. this should be a self-linked record field

let duplicatesField = table.getField(“Duplicate of”);

// query the table and find our record according to its id:

let query = await table.selectRecordsAsync();

let record = query.getRecord(recordId);

// search for duplicates

let foundDuplicates = query.records.filter((potentialDuplicate) => {

// if they're the exact same record, they're not duplicates:

if (potentialDuplicate === record) {

    return false;

}

if (potentialDuplicate.name === record.name) {

    // if the names match, we've found a duplicate:

    return true;

}

return false;

});

console.log(Found ${foundDuplicates.length} duplicates of ${record.name});

// save the duplicates:

await table.updateRecordAsync(record, {

[duplicatesField.name]: foundDuplicates,

});

Did you set up your input config variable for recordId? You configure inputs to the left of the script editor.

Yes, I did configure the inputs on the left side. RecordID.

Ty,
Sharon

Sharon Gay Phelps, Realtor®
Howard Hanna Real Estate Services
216.331.8743
sharongayphelps@howardhanna.com
sharongayphelps.howardhanna.com

What’s Your Home Worth?

Get up to three automated Estimates - Instantly.
No cost, and no obligation.

My Reviews – Read them, Write one, Thank you!

Nothing contained in this email shall be deemed to constitute or form the basis of an offer, acceptance, counteroffer, contract, agreement or other binding obligation until and only if also delivered and executed in writing between appropriate parties.

Make sure the capitalization of the input variable matches what you’ve typed in the script, and try pulling the record ID directly and not from a calculated field value

Sharon_Phelps
4 - Data Explorer
4 - Data Explorer

Thank you. There was a discrepancy with the capitalization. Now it works.