I’ve got a base I use to track my clients and the coaching sessions I have with them. Two tables: Clients
and Sessions
. The Sessions
table has a link to the Clients
table to display the client name.
The Clients
table has various data about the clients themselves including a checkbox field called Paid
that tracks whether this client is a Paid or Pro Bono client. (The status of the checkbox could change over time. For example, a pro bono could become a paid client at some future point.)
The Sessions
table has data about the date, length of the session, etc. including whether it was a paid or pro bono session.
Here’s what I’d like to do:
When I create a new record into the Sessions
table, I want Airtable to check the Paid
field in the Sessions
table if that client has a check in the Paid
field of their record in the Clients
table.
I have two input variables: recordId
which is the ID of the newly created record, and client
which is the ID of the client in the newly created session record.
My code:
let sessionsT = base.getTable('Sessions');
let clientsT = base.getTable('Clients');
let inputConfig = input.config();
let record = inputConfig.recordId;
let client = inputConfig.client;
let clientsResult = await clientsT.selectRecordsAsync();
let paidClient = clientsResult.getRecord(clientc0]);
if (paidClientC0] == true) {
let update = await sessionsT.updateRecordAsync(record,
{
'Paid': true
}
)
};
The script fails, and I can see that I’ve not getting the status of the Paid
field in the Clients
table populated.
Any suggestions? I’m a lot more accustomed to regular SQL querying and such, so I’m trying to wrap my brain about the AirScript concept.