Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Mar 13, 2024 06:57 AM - edited Mar 13, 2024 07:22 AM
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:
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:
// 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
Mar 13, 2024 07:25 AM
Rather than updating the record in the script, add some output from the script like `output.set('chosenLink', chosenLink)` and then add a separate Update Record step. This will allow you to test more easily and see that the `chosenLink` output is what you expect. Are you sure that the `unnassignedLinks` is an array of record ID's? And not an array of records or something else? You can always `console.log()` things at various steps in your code so you can see the values when testing.
Mar 13, 2024 07:25 AM
Could you provide a screenshot of your automation setup as well as how you're setting up your input variable? (If you could provide a read only link to your base that'd be best as that'd include the automation setup and would make things a lot easier to debug)
Could you do a console.log of unassignedLinks?
Mar 22, 2024 08:46 AM
Thank you Adam!
Here are a few screenshots of the automation setup in Airtable. The read-only link should be this one: https://airtable.com/appX64txDWlNUmTGO/shryhyKtLyjgBdQiH, but when I look at it in an anonymous browser I'm not able to see the automation details so I may have the wrong settings enabled.
I will reply again with a console.log as soon as I can.
Mar 22, 2024 08:55 PM
Hi Alex, for your input variable, could you try setting it up so that it uses the Airtable record IDs instead like so?
The error in your screenshot also seems to indicate a new error where that field can't be found; if you could change that field ID value back into the field name that should remove that error as well I think