I'm working on an automation that is triggered when a record is created.
Here's how it works:
I have a Fillout academy registration form with the action create a record on Airtable in the Sourcing table;
When the user submits the form, a record is created in the Sourcing table and triggers the automation to perform the following actions:
- Retrieve and check if the selected course exists;
- Check whether a learner or candidate already exists, using the email address as the unique field in the Learner table;
- If the candidate exists, we check if he/she has an existing sourcing, taking the existing candidate and the training course as parameters;
- If the sourcing doesn't exist, I proceed with the relationship between the existing candidate and the course (thus updating the newly created sourcing by attaching the existing candidate);
- If the candidate does not exist, I create the candidate in the Learner table and link it to the sourcing created in the Sourcing table;
- If the candidate exists and the sourcing also exists, I update the old sourcing by changing its status to "Duplicate".
But here's the problem: if a user submits the form with the same training several times, I end up with several sourcings created for the same candidate.
I'd like to do this, find a way to detect if the candidate already contains two sourcings, the third should merge with the most recent and delete it right after.
How can I do this in the same automation?
Thanks