Button to add a child record

Hi

I want a base to hold steps in a product roadmap (Topics) and allow for sub-topics below them to be created that reference the parent

Effectively a row is identified by TopicID, I want a button that runs a script that creates another row and places the TopicID of the current row into ParentID of the new row.

Really it’s for simple data entry (I know I could use Make, etc. but rather keep it inside AT if possible). I find the idea of using a Link to the table really clunky for fast entry

I’m new to AT scripting (but have reasonable scripting and programming background) but am getting nowhere to try and find the info to achieve this

Thanks for any ideas
Mike

1 Like

Do you want a button field in a data view? If so, you will need to use Scripting Extension.

Do you want a button element in an interface? If so, you could have the button run automation. The automation could then create the new record, either using no-code actions, or with a script.

If you are okay with triggering the automation with a checkbox field or single-select field, you could use a no-code automation in a data view.

If you want to learn more about Airtable scripting, have you looked over the scripting documentation?

Hi Kuovone

I want to use a scripting extension and have got that far. My question is around the actual script involved. I’ve looked through documentation and struggling to see how to get a value from the current row and create a bew row using it

Mike

1 Like

What does your script currently look like?
Have you looked at the example scripts to see how they work?

Yes and can’t find anything as I’ve already mentioned

Welcome to the community, @mball213!

Is there a reason you want to use a button + the scripting extension?

I don’t know scripting, but I ask because as @Kuovonne mentioned above, this can be done natively in Airtable’s automations without using scripting at all.

You would just need to trigger it differently than a button, such as using a single-select field or a checkbox field.

(And yes, it’s odd that Airtable’s button fields can’t run automations, but button elements in interfaces can.)

2 Likes

Thanks Scott.

Just think it’s more usable. I guess the checkbox option is no different but as a quick data entry mechanism it’s clunky and simply not what a checkbox is designed to do, that should be a button!. Seems constant compromise to perform pretty straightforward and simple expectations

Reality is looking more like I use Clickup or Monday.com to do this

The question is still a useful one moving forward though for other scenarios. Is there a way of getting the current row, and a field in the current row in a script. I’ve searched and searched and it seems not. Done it with Make but that seems ridiculous to be honest

All I can find is prompting the user for what row I want. Simple the CURRENT one

AI’s reponse is quite funny “Airtable’s scripting is very limited and this cannot be achieved”

1 Like

The AI doesn’t know. Scripting is actually quite robust & powerful in Airtable.

When you run a script from a button, you don’t need to use the record picker at all. You can skip the record picker altogether, and just have your script use the current record that the button was clicked on.

This is demonstrated in the sample scripts and in the scripting documentation. @kuovonne also asked you above what your script currently looks like, so she could help you further.

However, you will still have the same problem with running a script from a button, which is that the extension window pops open every time, which is probably not the best user UI experience.

In my opinion, for something as simple as this which doesn’t need to be scripted at all, your best bet is to use a single-select field, which looks very similar to a button but can also change to provide additional status updates to the user while your automation is running, such as “automation running”, “error”, or “done”.

Some information on this technique here:

If you are using Scripting Extension with a button field, you can get the row for which the button was pressed. It is in the scripting documentation here.

If you are using a button element in an interface, you can get the record from the triggering step of the automation.

If you are using scripting extension without a button field, there is no “current record” for the script. Scripting cannot tell which records are selected in a data grid view.

Scripting Extension cannot get the “current field” but you can hardcode the field, have the field set in script settings, prompt the user to select a field, or analyze the existing fields to determine what field to use based on field properties (such as the field type).

1 Like

Scripting should be able to if you press a button on a row. The select will work but it’s two clicks which gets multiplied out for every row you do it on.

Thank you both for your efforts to help. It leaves me very disappointed but I’m getting used to that with Airtable to be honest. Wants to be an Enterprise tool but it’s not fulfilling that promise

1 Like

It does. We’ve already said this multiple times.

Forget it. All the examples I am being sent again and again I’ve read and they prompt the user

Thank you for your time

The scripting extension actually comes with a sample script called “Record Picker” which shows you how scripts that are run from a button field will use the button’s record instead of using the record picker.