Help

This is automations bug or code fault

Topic Labels: Automations
539 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Edvardas_Kutkau
4 - Data Explorer
4 - Data Explorer

2fef012ec1d5ffb8d5ae9f1974280e24

Hello, sometimes airtable automations return bad input variables after changing record input value.

I changed DESIGN_STATUS to Needs fixing, and Customer_status field changed to Waiting via automation. But my code says that when status become Needs fixing, it need to do other thing.
Its happens very rarely.
This is my code problem or air table ? What I need to do ?

My code:

let data = input.config();

let table = await base.getTable('Orders V3');

let view = await table.getView("FULL ORDER LIST AUTOMATIONS");

if(data.Design_status == "Needs fixing"){

    await table.updateRecordAsync(data.RecordId, {"Customer_status": {"name": "Needs revisions"}});

} else if(data.Design_status == "Supervisor approved"){

//Time to send reminder

const sending_time = new Date( Date.now() + 2 * 24 * 60 * 60 * 1000 )

var dd = String(sending_time.getDate()).padStart(2, '0');

var mm = String(sending_time.getMonth() + 1).padStart(2, '0');

var yyyy = sending_time.getFullYear();

var today = mm + '/' + dd + '/' + yyyy;

let query = await view.selectRecordsAsync();

var records_to_update = [];

for (let record of query.records) {

    if(record.getCellValueAsString("Name") == data.ID){

        records_to_update.push(record.id);

        if(record.getCellValueAsString("Design_status") != "Supervisor approved") {

            records_to_update= [];

            break;

        }

    }

}

if(records_to_update.length > 0) {

    for (let record_id of records_to_update) {

        await table.updateRecordAsync(record_id,{

            'Cron_time': today,

            'Sended': true,

        })

    }

    

      


}

await table.updateRecordAsync(data.RecordId, {"Customer_status": {"name": "Waiting"}});

}
1 Reply 1

Check the run history for your automation to see what values are being passed into your script through input.config(). For this particular record, was Needs fixing the value that was passed in on your Design_status variable or something else?