Skip to main content

I'm creating a script between 2 tables: 'Engagements' and 'People'.

  • Engagements is a list of event attendance
  • People is a master list of people

I have a script that, using the attendance sign up info (name, email), tries to find a matching person from the master list. (This step is part of a loop to go through each Engagement record.)

 

let peopleTable = base.getTable('People'); // find a matching Person record let personQuery = await peopleTable.selectRecordsAsync({ fields: ['Person IDENTIFIER'] }); let foundNames = personQuery.records.filter((record) => { let name = record.getCellValue('Person IDENTIFIER'); return name == engagement.getCellValue('Person IDENTIFIER'); });

 

This works fine. Now I need to link all the 'foundNames' to that 'engagement' record.  The linked field is called 'Person' in 'Engagements' table:

 

let numPeople = foundNames.length; if (numPeople > 0) { await engageTable.updateRecordAsync(engagement, { 'Person': [{ id: foundNames.id }] }) }

 

This doesn't seem to be the right syntax. I'm probably missing one more variable. How do I insert the array of all 'foundNames id's to this linked field?

 

I figured this out:

// create a new array of all matching People found let foundNamesIDs = foundNames.map(record => ({id: record.id})); // update the Engagement with all names await engageTable.updateRecordAsync(engagement, { 'Person': foundNamesIDs })