I’m looking to use the suggested Mark Duplicate script within the scripting app. I copy and pasted the script, ensured I had the linked “Duplicate of” field made (or at least I think I made it properly ) and yet I get the error:
TypeError: Invalid arguments passed to recordQueryResult.getRecord(recordId):
• recordId should be a string, not undefined
at main on line 14
Click to see the script provided within the app
// the table to check
let table = base.getTable(“Feature requests”);
// 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, {
AduplicatesField.name]: foundDuplicates,
});
Not being a person who does script myself, I’m unclear on how to resolve. Any help would be greatly appreciative.
I’m looking to use the script to identify those which have already applied to our program, and therefore are already in our database so that we can review the past application along with the new one and forego having to search for a duplicate of each new applicant manually.