Write modes
Last updated
Last updated
When you run a request, the API response data is transformed from its original format (JSON/XML/CSV) into tabular data (records and fields) and written to your output table.
The tabular data can be written to your output table in two different ways, determined by the Write Mode:
Append - Add the records to the output table as new records.
Update - Update existing records in the output table, (optionally) create leftover records and (optionally) delete records not found in response.
There are more details and examples of the two write modes below.
On the create request screen, click to open the advanced settings.
Under Write Mode, select the write mode you want to use.
The Append write mode simply adds new records to your output table. None of the existing records in your output table will be modified. This write mode is useful when you want to pull in new data at set time intervals and add it to your existing data.
Let's say the existing data in our output view in Airtable is:
And the API response data (after being transformed from JSON) is:
After a run with the write mode set to Append, the output view will be:
We could run this request every day, add a 'Created time' field in Airtable, and look at how the 'Units sold' field for a particular item changes over time.
The Update write mode first updates the existing records in the output view.
If there are more records in the response than in the output view, the leftover records will be created as new records in the output table. You can also turn this behaviour off.
Using the same example values from the Append example above, let's say the existing data in our output view in Airtable is:
And the API response data is:
After a run with the write mode set to Update, the output view will be:
The first two records in the output view were updated with the first two records in the response data. Then a record was created for the third record in the response.
There is a problem in this scenario. Before we ran the request, the first record in our output view was associated with the 'Orange Hat' item. Now it's being used for 'Blue T-Shirt' and a different record is associated with 'Orange Hat'.
If we had linked other records to this record, added comments or values in other fields, these would now be associated with the wrong item.
We can avoid this by setting the Update Based on Field(s) to 'Item Id', a unique field that Data Fetcher can use to match the items in the response to those in the output view.
After a run with the Update Based on Field(s) set to 'Item Id', the output view will be:
Data Fetcher will only look at the records in your output view, not the entire output table. So if you have filters applied to this view that prevent it from finding a matching record, a duplicate record will be created. To avoid this, use an output view that has no Airtable filters applied.
By default, leftover records will be created as new records in the output view. To toggle this behaviour on or off:
Under Write Mode, toggle "Create records leftover after update" on or off.
This option is only available when the write mode is Update.
You can tell Data Fetcher to delete any records in the output view that are not found in the API response. This setting is useful when the application you've connected to has deleted some data and no longer displays it in the API response. You'd want to delete the records in Airtable to reflect this change.
Under Write Mode, toggle "Delete records not found in the API response" on or off.
Data Fetcher will only look at and delete the records in your output view, not the entire output table. Select an output view with no Airtable filters to ensure it deletes all the records in the output table not found in the API response.
Item Id | Item name | Units sold |
---|---|---|
Item Id | Item name | Units sold |
---|---|---|
Item Id | Item name | Units sold |
---|---|---|
Item Id | Item name | Units sold |
---|---|---|
Item Id | Item name | Units sold |
---|---|---|
Item Id | Item name | Units sold |
---|---|---|
Item Id | Item name | Units sold |
---|---|---|
On the create request screen, click to open the advanced settings.
On the create request screen, click to open the advanced settings.
229
Orange Hat
5
107
Purple Skirt
10
692
Blue T-Shirt
7
229
Orange Hat
10
107
Purple Skirt
17
229
Orange Hat
5
107
Purple Skirt
10
692
Blue T-Shirt
7
229
Orange Hat
10
107
Purple Skirt
17
229
Orange Hat
5
107
Purple Skirt
10
692
Blue T-Shirt
7
229
Orange Hat
10
107
Purple Skirt
17
692
Blue T-Shirt
7
229
Orange Hat
10
107
Purple Skirt
17
229
Orange Hat
10
107
Purple Skirt
17
692
Blue T-Shirt
7