I need to set up a workflow where users register through a form with their email address, and in some cases, an optional Group ID I will pre-fill using URL parameters. Those users then need to be assigned a unique URL (taken from another table) and then they need to get an email that confirms their registration and shares that URL.
To do this, I have two tables:
- registrationInfoTable: Captures email addresses (and sometimes Group IDs)
- testLinksTable: A static list of all the available unique URLs.
My test base is here for reference: https://airtable.com/appX64txDWlNUmTGO/shryhyKtLyjgBdQiH
The automation I've been using is called "Update registration with testLink" and features the following steps:
- Trigger: When a record is created in registrationInfoTable. I have also tried a form submission trigger and they seem to be the same in my case. This seems to be working.
- Find records: I have a formula in the testLinksTable that designates each link as "assigned" or "unassigned" based on whether that record is linked to a record in the registrationInfoTable. This seems to be working.
- Run a script: This seems to be where things are failing for me. I want the script to take the input from step 2, select just one of those, and create the connection between the two tables, which should automatically put a single unassigned link over for that user. Here's the script:
// Linking the table
let table = base.getTable('registrationInfoTable');
// Assume 'unassignedLinks' is passed as an input variable to the script
let inputConfig = input.config();
// Array of Record IDs from the 'Find Records' step
let unassignedLinks = inputConfig.unassignedLinks;
// Record ID from the trigger step
let newRecordId = inputConfig.newRecordId;
// Ensure there are unassigned links to choose from
if (unassignedLinks.length > 0) {
// Choose the first unassigned link from the provided array
let chosenLink = unassignedLinks[0];
// Ensure we have a valid Record ID for the new registration and a chosen test link
if (newRecordId && chosenLink) {
// Update the registrationInfo record with the chosen testLink
await table.updateRecordAsync(newRecordId,{['testLinks']: [{id: chosenLink}]
});
} else {
console.error('Error: Record ID or chosen test link is undefined.');
}
} else {
console.error('No unassigned testLinks available.');
}
When I run this, I get the following error code, which I haven't been able to figure out:
ERROR
Error: Field "fldCNPJxVSoQjRW55" cannot accept the provided value.
at main on line 22
When I looked into it, fldCNPJxVSoQjRW55 is the testLinks field in registrationInfoTable, which is the field I use to associate the records across the two tables. Maybe there's some kind of a limitation to this kind of field? I'll try just pulling the URL across but then I will need to write some kind of a script that would designate the chosen URL as "assigned" so it doesn't get picked again and I don't know how to do that.
I've been looking through Community posts for a few days now and am still having issues getting my automation to work, which is why I'm posting this here. If there are other threads you think might solve my problem I welcome the help. Once I've figured this out, then I need to add a step (or add a new automation flow?) that will send the user an email.
Thanks so much!
~Alex