Recordpicker button and adding a blank row

Hi guys
I hope some of you scripting geniuses can help me.
I have a button In a task list and want to add a button to add a new row in that list under that project instead of clicking the “plus sign” underneath the row.
Can someone help me with the script?
Sinve I have the button and record picker script we know what row we’re at so to add a row/task shouldn’t be so complicated? But its complicated for me…
The script look like this know :

// Change this name to use a different table
let table = base.getTable(“Tasks”);
// Prompt the user to pick a record
// If this script is run from a button field, this will use the button’s record instead.
let record = await input.recordAsync(‘Select a record to use’, table);
if (record) {
// Customize this section to handle the selected record
// You can use record.getCellValue(“Field name”) to access
// cell values from the record
output.text(You selected this record: ${record.name});
} else {
output.text(‘No record was selected’);
}
Much appreciated if someone could advice.
Jesper

Welcome to the Airtable community!

You can use createRecordAsync to create a new record, but you cannot control where in the user interface that new record will appear. That depends on the filtering and sorting of the current view. You can see more in the documentation.

Hi Kuovonne!
Thanks for the feedback. I tested the createRecordAsync and as you mentioned it just adds a record all over the place:-)
I thought the button and record picker showed the location.
The task list is sorted by “Project name” and then there is “Tasks” under each project.
Each task have now the “Add task” button that I want to add a empty row under.
Is there any way to combine the record picker script and createRecordAsync to make this work?
Regards
Jesper

The record picker gives you the record. However, the record is not aware of where it is compared to other records. Indeed, the record is not aware of other records in the table at all (unless they are linked). Records can also appear in different orders in different views. This is part of the architecture of Airtable.

OK, understood.
Can I somehow make this work in with another approach/script?

You can set the grouping/sorting for the view, and then create the new record with field values that will put the record in a specific place based on that grouping/sorting.

Or you can use shift+enter on the keyboard to create the new record instead of a button.

Yes the view is already grouped by “Project”, sorry if I wasn’t clear. My bad.

The reason for the button is that in the Interface Beta you can’t add new tasks (record picker)if there already is a record there (a task).

A script won’t help you in an interface. Buttons that run scripts don’t work in Interfaces. Are you trying to add a new linked record? You either need to use the linked record field (not a grid) or an automation.

Thanks kuovonne for your patience and answers.
Ok so buttons with script don’t work.
But it is a linked record field in Interfaces and I can only add a new linked record if there is non there before, see pics.


I was thinking if I added a button with a script in the table, I could open the record in Interface(doubleclick so I see all the fields) and click the button.

Is your field configured to allow linking to multiple records?

Bingo!! you just saved me another day of head scratching and frustration!
Now I can Add when there is already records there.
Thanks Kuovonne!

/Jesper

1 Like

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.