Help

Conditional automation for repetative actions

Topic Labels: Automations
889 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Milena_Moscicka
4 - Data Explorer
4 - Data Explorer
Hi! I have two related tables - Challenges and Services.
In Challenges I have records with sports challenges and their characteristics - e.g. ID number, name, months in which they take place, pricing. For every challenge I should have a service(s) (e.g. organizing the event / creating promo materials) in a Service table.

I created an automation, which should work like this:
1. Trigger: A new record is created in the Challenges table
2. Condition: If in the newly created record (challenge) "Pricing" field is "Standard Pricing 2023" -> the automation should continue, if not -> nothing should happen
3. Action: If the above condition is met, the action is to create a new record (service) in the Services table for EACH month of the challenge.

The "Months of the challenge" field is a multiple select field in Challenges table, where you can select many months in a format: 24/01, 24/02, 24/03... and for every of this individual month in the newly created challenge a service should be created, but only if the pricing is "Standard pricing 2023").

I did it with a script (as a form of condition), but no matter the result (true / false), the automation continues and creates services for every new challenge, not only for those whose Pricing is "Standard Pricing 2023".

I see that for "single actions" like creating just one sevice, in the Action configuration (in the automation settings) I can add a condition -> if the script result is e.g. true / false -> continue. But there is no such configuration for a repetitive action ("for each month create a sevice").

I tried to do it in different ways -> I created "Find record" condition before the action, and also tried the same but within the Action configuration. It doesn't work. The last attempt was with a script.

I'm not a coder so the script that I have may also be wrong, so please let me know if such conditional repetitive automation is DOABLE in Airtable and I just did something wrong (and how to fix it) or maybe you know that Airtable doesn't support such automations.

My script is below:
let inputConfig = input.config();
let recordId = inputConfig.recordId;
let table = base.getTable("Challenges");
let record = await table.selectRecordAsync(recordId);

if (record.getCellValue("Pricing") === "Standard pricing 2023") {
    output.set("createRecord", true);
} else {
    output.set("createRecord", false);
}

 

0 Replies 0