Update based on field(s)
Last updated
Last updated
If you're using the Update write mode and each record in your API response has a unique field, such as an id
field, you can use this field to merge the response data with the existing records in your output view. See the example below to understand why this is helpful.
On the create request screen, click to open the advanced settings.
Under Write Mode, ensure 'Update' is selected.
Under Update Based on Field(s), select the field from your output table. You can select more than one field if needed.
When you are running on multiple records, you should usually keep Update Based on Field(s) set to 'None'. The output record's position in the Run on Multiple Records table/view will then be used to update it.
We can understand why we need this with an example. Let's say the existing data in our output view in Airtable is:
229
Orange Hat
5
107
Purple Skirt
10
And the API response data (after being transformed from JSON) is:
692
Blue T-Shirt
7
229
Orange Hat
10
107
Purple Skirt
17
After a run with the write mode set to Update and Update Based on Field(s) set to 'None', the output view will be:
692
Blue T-Shirt
7
229
Orange Hat
10
107
Purple Skirt
17
The issue here is that before we ran the request the first record in our output view was associated with the 'Orange Hat' item. Now the first record is being used for 'Blue T-Shirt' and the second is associated with 'Orange Hat'.
If we had linked other records to the first record, added comments or values in other fields, these will 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 table will be:
229
Orange Hat
10
107
Purple Skirt
17
692
Blue T-Shirt
7
Perfect! Now the Units sold
values and Item name
field values have been updated (although only the Units sold
values changed), by using the unique Item Id
field to merge the records.
Data Fetcher will only look at the records in your output view, not the entire output table. So if you have filters applied to the output view that prevent it from finding a matching record, a duplicate record will be created.