Auto-filling values into create forms

How to pre-fill data in create forms

Create forms can be auto-filled with certain values by constructing an Auto-fill URL. You can then add this in to your app as a button to allow your users to create new records with some fields already filled in for them.

Auto-fill only works on create forms.

Where and how you do this is dependent on what the intended function of the URL will be...

If you want to autofill your create form with a static field e.g. a fixed Type or Status and you want the button for this to be within each detail record view, you can add in a button by dragging a new 'Banner' container in and then adding in your Auto-fill URL directly into the box.

However if you want to autofill your create form with a variable field i.e. something dependent on the current record you are in, using linked records etc, or you want to display your button on a list view - you need to add in your autofill URL as a new field in Airtable.

Auto-fill links must be in the following format:

/page/new?autofill__field=ABC

We recommend using a relative link format i.e. not containing the start of your app URL (e.g. testapp-1.my.stacker.app) just in case you decide to change it or use a custom domain, then you won't need to update this URL too.

  • where /page/new - is the extension of the URL for the create form of the page you want to add a new record to. For example in one app where we would like to autofill values in the create form for the 'Members' page, the URL extension can be seen as /members/new

  • field is the developer name of the field to be filled

Auto-fill multiple fields by adding the & separator in the url that you create.

e.g. /page/new?autofill__field=ABC&autofill__field2=DEF

To find the developer names, from Setup Home, go to the Fields configuration for the table.

Toggle on "Show developer name". The developer name appears underneath the user-facing name for each field below.

Note that the developer names are all lower-case and are case-sensitive.

Field Types

The following field types are supported:

  • Text-type fields, such as Text and Long Text.

  • Dropdowns. For multi-select dropdowns, only a single value can be auto-filled.

  • Link to another record. These can be filled using the Stacker ID for the record (see below). For link fields which can take multiple values, only a single value can be auto-filled.

  • Checkboxes can be filled by supplying the value true or false.

  • Numbers, Percentages and Currencies. Percentages should be supplied as a fraction, so 40% is given as 0.4 in the URL.

To fill a link to another record, you will need the Stacker ID for the record to be linked.

This can be found at the end of the URL of the record detail page.

If you need to auto-generate the auto-fill URL, the Stacker ID consists of a static Stacker table prefix, an underscore The Stacker ID consists of a static Stacker table prefix, an underscore and the Airtable Record ID if your data comes from Airtable.

You can find out the static Stacker table prefix for the record(s) you want to autofill by going to the list view for the records, clicking on one of the records to go to the detail view and observing the URL. In the example above 'dog' is the static prefix for the records in the 'Dogs' table.

If you use Google Sheets, the ID will either be the record's row number in the sheet, or the Stacker ID listed in the Stacker ID column in your sheet.

How to use your auto-fill url

Once you have constructed your url you can use this in your app in a couple of ways:

  • You can add it directly by including a banner in a detail view and pasting your URL into the 'Button URL' box and adding a label (see example below).

This method can only be used if you want to autofill your create form with a static field i.e. you wanted a fixed value inputted.

  • You can alternatively add your URL into your Airtable base in a URL field and display it as a button. You can add this button in the list view or the detail view.

This method requires you to enter the URL for each record individually!

You may wish to have a button that autofills a create form based upon the specific record the button is pressed in - for example, you could create a new order for a particular item in an inventory table. Rather than having to manually formulate the URL for each individual record, we can use a formula in Airtable to do it automatically.

Our formula will take the following format:

'/orders/new?autofill__inventory=inv_'&{Record ID}&'&autofill__type=Installation'

  • Where we use 's to ask Airtable to 'print' this text, so anything between these will be static. Then we use the & to tie the two aspects together (it is not used here in the same way as in the actual URL) and then {Record ID} is asking Airtable to fill in information for each specific record (in this example the record ID which you will need to generate by adding in an additional formula field with the formula RECORD ID())

Using this method, we only need to input the formula for the URL once and then Airtable will generate the link for every record added!

You can then add in your formula field to either the detail or list view and treat as a URL, switching it to a button as in the example previously.

In the above example, we are generating a URL to be displayed as a button in the Inventory page, which autofills a new Order record with the linked record field as the specific inventory item within which the button is pressed, as well as the order type being fixed as an Installation.