In this article, we’ll demonstrate how to dynamically generate an Airtable script that initiates a Documents process through automation. Airtable automation provides flexible and powerful tools for automating tasks, and it’s quite easy to set up. You’ll learn just how effortless it is to embed a button within the Airtable interface and generate documents based on your data.
For demonstration purposes, we created an Airtable database Client orders from the Product catalog template.
Also, we added an Airtable interface from the Client orders database to add automations on further steps.
Note
Please read more about creating and using Airtable interfaces in the documentation.
Before using the Airtable automations we need to set a Documents process that will generate an invoice from a DOCX template.
Register or log in to your Plumsail account.
In the Processes section, click on the Add process button and select Start from template.
In the Documents template library find the Airtable template.
Name the process and click Next to proceed. On the next step you can adjust the document template to your needs.
Note
Check how Plumsail Documents Word DOCX templates work here.
The default template already reflects all the fields from the Airtable demo database. We’ll stay with this one.
Click Save & Next to go to the Settings substep.
Configure the output file format and other settings, and find more information about these settings in the user guide.
In this article, we’re adding Gmail delivery. There are many other delivery options available; please check them.
You can configure as many deliveries as you need.
We will start the Process from the Airtable automation.
Open the Airtable interface, click + Add Extension button, find Plumsail Documents extension and add it to the database.
You’ll need to connect your Plumsail account to complete the connection. Please sign up if you don’t have the account yet.
These are the settings we use for this example.
Process to start. We select the Airtable invoice process created previously in the article.
Button title. We name the button as Send invoice.
We’ll generate a Document for each record.
We won’t Download result document but Attach result document to the record - to the Invoice field.
Note
Please find all the details about working with the Airtable extension here.
After saving the extension settings click on the button settings again to open it.
Expand the Advanced section and click the Generate script button.
You’ll see a ready-to-use automation script. Click Copy script, then Back and close the settings.
Now let’s go to the database interface and open it for editing.
Then let’s add a new action.
Click Buttons -> + Add button action.
We name the button as Send invoice. Also select the action Run automation in the dropdown.
There is no automation yet. So, we open the automation dropdown and click + Create new automation.
Let’s name it as Start invoice process and click Continue in Automations.
We have a trigger When button clicked. Click on the + Add advanced logic or action.
And select new action Run a script.
Paste the code copied from the Documents extension settings in the previous step into the Code window.
The generated script simulates the functionality of the Send Invoice button we added as an extension, initiating the same Documents process from the Airtable interface. If you modify the button settings, you will need to generate the script again and update it in the automation. Ensure that all tokens from your Documents template and any new fields from the database table are accurately represented in the new script.
The last step is to create a new input value called RecordID and assign the Airtable record ID to this value.
You can test the script afterward and turn it on for further usage.
Then go to the interface and publish it.
And now you can generate new invoices from the interface with the Airtable automations.
The generated invoices are attached to the invoice field in the database.
The same invoice is also sent using Gmail delivery to the recipients.
Note
Explore all other features provided by Airtable Automations.
That’s it! If you’re new to Plumsail Documents, register an account to get a 1-month free trial and explore all these features and more.