Development tools

Creating and updating a record in an Airtable table using Latenode

Avetis Grigoryan
Senior Developer
August 15, 2023
A low-code platform blending no-code simplicity with full-code power
Get started free

Introduction

Let's set up a script that allows using "Latenode" to create and update a record in the table from the database "Airtable";

Airtable Preparation

Go to the "Airtable" website;

Links to all the sites are at the bottom of the article;

If you already had tables, go back to the home page, create a new one using the "Start from scratch" button and select "Kanban";

‍

After creating, select the "Priority" column in the bottom menu, and check that "Status" and "Assignee" were also selected;

‍

If you are just signing up, select "Tasks" in the step titled "Now, we'll add some info" to create a pre-built Kanban board with the three tasks already added;

Adding a personal token

Let's go to the "Airtable create personal token" link;

Click the "Create new token" button in the upper right corner;

Enter any name you like, for example "AirtableLatenode";

‍

In "Scope" add the following: data.records:read data.records:write schema.bases:read;

‍

Under "Permissions" select the desired "workspace" to which you want to grant access in order to manage it using the "API";

‍

Click "Create token";

Save the resulting token, for example for a while in a notepad;

Creating a project in Latenode

Go to our list of projects in "Latenode";

Let's create a new project;

Next create the first node "Webhook";

Copy its address into your rest client or notepad;

Saving the node;

Create a "JavaScript" (JS) node and copy the code from the article into it;

Code for JS node

let apiURI, personalToken, newTask, recordID;
	apiURI = "https://api.airtable.com/v0";
	personalToken = "Bearer [Insert your personal token in place of these square brackets]";
	newTask = {
		name: , // After the colon and before the comma, select the name field from the received query
		status: , // After the colon and before the comma, select the status field from the resulting query
		priority: , // After the colon and before the comma, select the priority field from the resulting query
	};
	if () { // Inside the parentheses, select the recordID field from the resulting query
		recordID = ; // After the equal sign and before the semicolon, select the recordID field from the received query
	} else {
		recordID = false;
	}
	
return {
	apiURI,
	personalToken,
	newTask,
	recordID,
}

For now, without changing anything, just save it;

Let's start the project;

Using the rest client, we make a request by inserting the address from the webhook node in the address bar;

Request for rest client


  curl --request POST --url [insert the address of your webhook in the Latenode project instead of these square brackets]
  --header 'Content-Type: application/x-www-form-urlencoded'
  --header 'Accept: application/json'
  --data 'name=Send data from Latenode!'
  --data 'priority=In progress'
  --data 'status=Medium'
  --data 'recordID='

Let's go back to the "JS" node and edit it;

Check that when you set the text cursor inside the node, this data appears in the side menu. If it doesn't, repeat running and calling the web hook;

Insert the data that was sent in the request into the designated places;

Saving our changes;

Create four new "HTTP request" nodes to get the list of databases;

And in each copy the code below and save, most importantly do not mix them up, you can give each a transparent name;

REQ01 Retrieve list of bases


  curl --request GET --url '[insert the apiURL variable from the JS node in place of these square brackets]/meta/bases'
  --header 'Accept: application/json'
  --header 'Authorization: [Insert the personal token in place of these square brackets]'

REQ02 Retrieve the schema and contents of the base


  curl --request GET --url '[insert in place of these square brackets the variable apiURL from the JS node]/meta/bases/[the ID of your base from the REQ01 query]/tables'
  --header 'Accept: application/json'
  --header 'Authorization: [Insert personal token]'

REQ03 Create a new entry in the task table

curl --request POST --url '[insert the apiURL variable from the JS node in place of these square brackets]/[The ID of your database received in query REQ01]/[The ID of your table received in query REQ02]' --header 'Authorization: [Insert personal token]'
	--header 'Content-Type: application/json'
  --data '{
	    "records": [
	      {
	        "fields": {
	          "Priority": [Substitute the variable priority from the JS node],
	          "Name": [Substitute the name variable from the JS node ],
			      "Status": [Substitute the status variable from the JS node]
	        }
	      }
	    ]
	}'
  

Now we will add one by one to the chain and call them to set up the data retrieval;

Change everything in square brackets to data from queries and other nodes;

In each you need to add the created personal token;

In those places where it is used to access arrays, specify the desired index, it begins with zero, as elsewhere, despite the fact that in the side menu the first will be number one;

In the add request, don't forget to check that POST is selected as the method type;

Below are screenshots of how each of these nodes should look in the end after all the edits;

After calling the query with adding a record, go to our table Airtable and check that there is a new task with the text "Send data from Latenode!", if not check each query individually, perhaps somewhere not replaced the data, forgot to substitute a token;

Let's delete this task;

At the end of the chain, let's add a "Webhook response" node for convenience;

Let's make it return the ID of the new record created;

Start the project and call Webhook;

Let's make sure that the object with record_id is returned in response to the request;

Let's go back to our task table and check that it was created;

I hope it worked out for you too;

Useful Links:

Basic:‍

‍‍

Latenode

Latenode scenarios list

Airtable

Airtable сreating a personal token (Airtable Developers)

Airtable templates

‍

Information:

‍

https://developers.google.com/gmail/api/reference/rest/v1/users.messages/send

https://developers.google.com/gmail/api/reference/rest/v1/users.messages#Message

Related Blogs