Help

How to refresh the view using airtable blocks sdk

Topic Labels: Custom Extensions
1257 3
cancel
Showing results for 
Search instead for 
Did you mean: 
Shang1128
4 - Data Explorer
4 - Data Explorer

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.

3 Replies 3
Tammy09
4 - Data Explorer
4 - Data Explorer

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

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.

Maxineburns23
4 - Data Explorer
4 - Data Explorer

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.