Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Jul 20, 2023 05:24 AM
Hi support team!
I am building custom extension using airtable blocks sdk.
Workflow here.
1. When I click "Get companies" button in extension section, the extension will call 3rd party API.
2. The API returns the result as a JSON format. Json contains record Ids of a table named "All companies".
3. After this, I want to refresh airtable view of a table that is selected record ids returned from API.
Is it possible?
Please help me, thanks.
Jul 24, 2023 03:37 AM - edited Jul 24, 2023 09:31 PM
Yes, it is possible to refresh the Airtable view after retrieving record IDs from a 3rd party API using the Airtable Blocks SDK. First of all you have Retrieve Record IDs from the 3rd Party API and Update the Table View. myfedloan org bill
Jul 24, 2023 07:35 AM
Hi Tammy. Thank you for your reply.
Yeah, I can get record ids.
Let's say, I have stored record ids into Array variable in block sdk code.
After this, how can I update the table? I meant , view refresh based on record ids.
Thank you.
Aug 02, 2023 10:26 PM
Hello,
Yes, it is possible to refresh the view of a table in Airtable using the Blocks SDK after you have obtained the record IDs from the 3rd party API and stored them in an Array variable. To achieve this, you can use the 'table.selectRecords' method provided by the Blocks SDK.
Create an Array variable and store the record IDs returned from the 3rd party API in this array. Get the instance of the table you want to update. You can use 'base.getTableByName' to get the table object. Use the 'table.selectRecords' method to select the records based on the record IDs stored in your Array variable. This will update the view and show only the selected records in the table.
// Assuming you have stored the record IDs in an array called "recordIds"
const table = base.getTableByName('All companies');
// Select the records based on the record IDs
table.selectRecords(recordIds);
// Refresh the view to show the selected records
table.refreshView();
By calling 'table.refreshView()' after 'table.selectRecords', you ensure that the view is updated with the selected records. The 'table.selectRecords' method can take an array of record IDs as an argument, and it will select only those records in the table view. Make sure you have the latest version of the Blocks SDK to access these methods and features. Remember to handle any potential errors or edge cases when working with APIs and record IDs to ensure a smooth user experience.