Example Script for Automations Mark Duplicates

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

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

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

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.