Help

Re: Prevent users from creating empty linked records when clicking the x on add record windows

Solved
Jump to Solution
1651 0
cancel
Showing results for 
Search instead for 
Did you mean: 
-Sam
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi Community,

I have interface with many layouts and with most, I have to allow users to (+ Add Records )  but then if they x out of that window it still creates an empty record and links it! how can I prevent this behavior and still give users the ability to link and or create new records from that button?

 

Sam_3-1688143263664.png

If users change their minds and decided not to create a new record and just click the X button without putting any data records still getting created!

 

Sam_0-1688142916124.png

Appreciate any input

1 Solution

Accepted Solutions
-Sam
5 - Automation Enthusiast
5 - Automation Enthusiast

Update, Airtable heard us and this has been fixed but ill share my work on this issue so maybe someone will benefit Old original comment:"Yup I figured, Thanks Scott, I solve it by creating automation that runs scrip when record created to check the minimum required fields, I used the below script on my "Rental table" to check the two mandatory start and end date filed, if these are empty the record will be deleted, I just have to create something similar for each table ."

Exept this didn't really work because the automation for record creation run immediately and doesn't give users a chance to finish editing and maybe enter the required fields, so my workaround was to make the automation check the record that created before the triggering record " the new record"   and that's how if users mistakenly linked incomplete record it will get clean up next time they create new record. I had to create a check box(create) and get that updated to checked with a button so the automation wont clean these records that has that check box checked.

 

 

 

let table = base.getTable('Rentals'); 

let fields = await input.config();

let StartDate = fields.startdate;
let Enddate = fields.enddate;
let ID = fields.ID;

if (!StartDate || !StartDate) {
    await table.deleteRecordAsync(ID);
  }

//this didn't work because automation runs immediately and setTimeOut function is not supported, this was my workaround attempt before Airtable make it right 

// record create automation to clean the previous record if "Create" checkbox was not checked.

let table = base.getTable('Rentals'); 
let fields =  input.config();

let ID = fields.ID;
let Create = fields.Create;
let Created = fields.Created;



let lastCreatedRecord ;
let count = 0;


queryResult.records.forEach((record) => {
  if (record.id !== ID && count < 2) {
    lastCreatedRecord = record;
  
  if (!lastCreatedRecord.getCellValue('Create')) {
     table.deleteRecordAsync(lastCreatedRecord.id);

  }

    count++;

  }
}


);
-------------------

//button code : to check the "Create" checkbox 

let table = base.getTable('Rentals'); 
let fields =  input.config();

let ID = fields.ID;

let queryResult = await table.selectRecordsAsync({
  fields: ['Create', 'ID'], 
});

let record = queryResult.getRecord(ID);

await table.updateRecordAsync(ID, {
    "Create" : true
    ,
})

 

 

 

 

 

 

See Solution in Thread

2 Replies 2
ScottWorld
18 - Pluto
18 - Pluto

Unfortunately, there is no way to prevent those blank records from being created in Airtable.

You could potentially create a nightly automation that cleans up all the "orphaned" blank records by deleting them. However, Airtable's automations don't natively allow record deletion, so you would either need to write a custom Javascript to do that or use an external automation tool like Make.

-Sam
5 - Automation Enthusiast
5 - Automation Enthusiast

Update, Airtable heard us and this has been fixed but ill share my work on this issue so maybe someone will benefit Old original comment:"Yup I figured, Thanks Scott, I solve it by creating automation that runs scrip when record created to check the minimum required fields, I used the below script on my "Rental table" to check the two mandatory start and end date filed, if these are empty the record will be deleted, I just have to create something similar for each table ."

Exept this didn't really work because the automation for record creation run immediately and doesn't give users a chance to finish editing and maybe enter the required fields, so my workaround was to make the automation check the record that created before the triggering record " the new record"   and that's how if users mistakenly linked incomplete record it will get clean up next time they create new record. I had to create a check box(create) and get that updated to checked with a button so the automation wont clean these records that has that check box checked.

 

 

 

let table = base.getTable('Rentals'); 

let fields = await input.config();

let StartDate = fields.startdate;
let Enddate = fields.enddate;
let ID = fields.ID;

if (!StartDate || !StartDate) {
    await table.deleteRecordAsync(ID);
  }

//this didn't work because automation runs immediately and setTimeOut function is not supported, this was my workaround attempt before Airtable make it right 

// record create automation to clean the previous record if "Create" checkbox was not checked.

let table = base.getTable('Rentals'); 
let fields =  input.config();

let ID = fields.ID;
let Create = fields.Create;
let Created = fields.Created;



let lastCreatedRecord ;
let count = 0;


queryResult.records.forEach((record) => {
  if (record.id !== ID && count < 2) {
    lastCreatedRecord = record;
  
  if (!lastCreatedRecord.getCellValue('Create')) {
     table.deleteRecordAsync(lastCreatedRecord.id);

  }

    count++;

  }
}


);
-------------------

//button code : to check the "Create" checkbox 

let table = base.getTable('Rentals'); 
let fields =  input.config();

let ID = fields.ID;

let queryResult = await table.selectRecordsAsync({
  fields: ['Create', 'ID'], 
});

let record = queryResult.getRecord(ID);

await table.updateRecordAsync(ID, {
    "Create" : true
    ,
})