Jun 12, 2020 09:39 AM
Hi!
I’ve been looking around the forum and Reddit for a solution to copy records from one base to another using the scripting block. I just want to know if this is possible and maybe see an example to use as a reference.
The idea is to get all the records from Base A Table 1 and copy them to Base B Table 1, without deleting existing ones. I need to have different bases so the data and permission management is easier.
Thanks for any help!
Solved! Go to Solution.
Jun 15, 2020 07:16 AM
Welcome @Sebastian_Murillo2!
As @Justin_Barrett mentioned, the scripting block API does not have any functions to perform inter-base calls (like reading/writing). Depending on your skill level, Justin’s recommendation for using a Zapier/Integromat integration is probably the most user-friendly option.
However, if you are looking for something more complicated, but Scripting Block-specific, you could use the Airtable Standard API which can perform read, write, update, delete operations for any base, given you have the base ID accessible.
To flesh this idea out a little further, imagine:
fetch()
call to the Airtable API for “listing records” (a GET request).createRecordsAsync()
pass in the response to copy the records into base A.Again, a little more complicated because you have to use two of Airtable’s APIs, but should be able to keep all the code within the scripting block.
Jun 13, 2020 12:22 PM
Welcome to the community, @Sebastian_Murillo2! :grinning_face_with_big_eyes: Unfortunately Airtable’s blocks, including the scripting block, can only access records within the base where they reside. Cross-base operations aren’t possible via blocks.
However, you can do what you want with the help of an integration service like Zapier or Integromat. I’ve got a video production base, for example, where I organize various video projects. When I change a project to a new status—e.g. from Pre-Production to Production—an Integromat scenario notices the change in that base, and adds records to my planning base for the tasks tied to that new status. Something similar could be set up to copy/update records between your bases.
Jun 15, 2020 07:16 AM
Welcome @Sebastian_Murillo2!
As @Justin_Barrett mentioned, the scripting block API does not have any functions to perform inter-base calls (like reading/writing). Depending on your skill level, Justin’s recommendation for using a Zapier/Integromat integration is probably the most user-friendly option.
However, if you are looking for something more complicated, but Scripting Block-specific, you could use the Airtable Standard API which can perform read, write, update, delete operations for any base, given you have the base ID accessible.
To flesh this idea out a little further, imagine:
fetch()
call to the Airtable API for “listing records” (a GET request).createRecordsAsync()
pass in the response to copy the records into base A.Again, a little more complicated because you have to use two of Airtable’s APIs, but should be able to keep all the code within the scripting block.
Jun 15, 2020 08:38 AM
Thanks a lot @Justin_Barrett and @Matthew_Thomas! Both answers are excellent I will explore both. Integromat for now just as a quick solution and the API script for the long road.
Best!
Jun 15, 2020 10:31 AM
Glad to know that you got the answer you were seeking! If you would, please mark the appropriate comment as the solution to your question. This helps others who may be searching with similar questions. Thanks!