Hi Lisa
First, glad to hear the script is helpful!
Second, there definitely is a way to use linked records instead. It just requires some slightly different code. This example base in our Universe has one way of doing it built in using a Scripting extension.
To answer your question around Automations (from DM)
I’ve added a version of my script (see below) for this you can use to adapt to your base. Note you’ll need to add some inputs from the Automation Trigger, to tell it which record to use (the record you want to create deliverables for).
Here’s how to setup the Automation
In your Automation, you’ll want to add input variables (left-hand side of the Automation Run a Script Action window) for the following:
deliverablesToCreate
=> this should be the multiple select field values inserted from your trigger step
recordID
=> this should be the Airtable record ID value inserted from your trigger step
Here’s the Automation-friendly version of the code where you’d want to update the variables before the “DO NOT EDIT” section:
let { deliverablesToCreate, recordID } = input.config(); // Values passed from the trigger record
console.log(deliverablesToCreate); // Log to console
let delivField = 'Deliverables'; // Field name or ID of multiple select field
let tableDest = base.getTable('tblXXXXXXX'); // Destination table name or ID
let destinationField = 'Name'; // Primary field name or ID you wish to populate the Deliverables name into
let projField = 'Projects'; // Linked record field name or ID back to source table records
//
//
// ———— * DO NOT EDIT * ————
if (deliverablesToCreate.length > 0) {
// Create records
let dToCreate = c];
for (let i = 0; i < deliverablesToCreate.length; i++) {
let name = deliverablesToCreate i]
dToCreate.push({
fields: {
fdestinationField]: name,
dprojField]: /{ id: recordID }]
}
})
};
// Batches the creation
while (dToCreate.length > 0) {
await tableDest.createRecordsAsync(dToCreate.slice(0, 50));
dToCreate = dToCreate.slice(50);
}
// Output confirmation for the user
console.log(`${deliverablesToCreate.length} records created
`);
} else {
console.log(`No deliverables chosen for this record. Make selections in the ${delivField} field first.`)
};
Hi Lisa
First, glad to hear the script is helpful!
Second, there definitely is a way to use linked records instead. It just requires some slightly different code. This example base in our Universe has one way of doing it built in using a Scripting extension.
To answer your question around Automations (from DM)
I’ve added a version of my script (see below) for this you can use to adapt to your base. Note you’ll need to add some inputs from the Automation Trigger, to tell it which record to use (the record you want to create deliverables for).
Here’s how to setup the Automation
In your Automation, you’ll want to add input variables (left-hand side of the Automation Run a Script Action window) for the following:
deliverablesToCreate
=> this should be the multiple select field values inserted from your trigger step
recordID
=> this should be the Airtable record ID value inserted from your trigger step
Here’s the Automation-friendly version of the code where you’d want to update the variables before the “DO NOT EDIT” section:
let { deliverablesToCreate, recordID } = input.config(); // Values passed from the trigger record
console.log(deliverablesToCreate); // Log to console
let delivField = 'Deliverables'; // Field name or ID of multiple select field
let tableDest = base.getTable('tblXXXXXXX'); // Destination table name or ID
let destinationField = 'Name'; // Primary field name or ID you wish to populate the Deliverables name into
let projField = 'Projects'; // Linked record field name or ID back to source table records
//
//
// ———— * DO NOT EDIT * ————
if (deliverablesToCreate.length > 0) {
// Create records
let dToCreate = c];
for (let i = 0; i < deliverablesToCreate.length; i++) {
let name = deliverablesToCreate i]
dToCreate.push({
fields: {
fdestinationField]: name,
dprojField]: /{ id: recordID }]
}
})
};
// Batches the creation
while (dToCreate.length > 0) {
await tableDest.createRecordsAsync(dToCreate.slice(0, 50));
dToCreate = dToCreate.slice(50);
}
// Output confirmation for the user
console.log(`${deliverablesToCreate.length} records created
`);
} else {
console.log(`No deliverables chosen for this record. Make selections in the ${delivField} field first.`)
};
@Alex.Wolfe , AMAZING, thank you SO much for this!
I did get one error:
Error: Field “fldjuDEGf1Rlj0WKg” cannot accept the provided value.
at main on line 61
Any idea for what I might have done wrong?
Update: @Alex.Wolfe , I think I figured it out! I had selected the linked record field rather than the multi-select field so I think that’s what caused the error! Switching it to the mult-select field made it work perfectly. THANK YOU!
Update: @Alex.Wolfe , I think I figured it out! I had selected the linked record field rather than the multi-select field so I think that’s what caused the error! Switching it to the mult-select field made it work perfectly. THANK YOU!
Awesome glad to hear you got this working!