Skip to content
How to create varia...
 
Notifications
Clear all

How to create variables

8 Posts
3 Users
0 Reactions
5 Views
Andrew_Davies
(@andrew_davies)
Posts: 8
Active Member
Topic starter
 

Hi

Does anyone know if it's possible to:

  • Retrieve some data (in my case Airtable) and use the values as a field name in a second search module?

In essence, I'd like my Airtable data to contain the names of fields that will be retrieved in another Airtable base – allowing me to create some custom reports/tables.

Thanks
Andrew

 
Posted : 04/08/2023 12:30 pm
Pro_Tanvee
(@pro_tanvee)
Posts: 3
New Member
 

Here’s how you can approach this scenario:

  • Utilize the “Search Records” module in callin.io to retrieve data from your initial Airtable base. This module will furnish you with a list of records, each containing field names and their respective values.
  • Incorporate an “Array Iterator” module following the “Search Records” module to loop through each record in the list.
  • Within the array iteration, you can employ dynamic field mapping to extract field names from the current record. Map these field names to a variable using the “Set Variable” module.
  • Add a “Search Records” module for your second Airtable base. In the field mapping section, use the variable holding the dynamic field name as the field to search within.
  • The array iteration will repeat these actions for every record, dynamically applying the field names to locate corresponding values in the second Airtable base.
  • After obtaining the records from the second Airtable base, you can map the retrieved data to generate custom reports or tables.
    Best Regards
 
Posted : 04/08/2023 2:20 pm
Andrew_Davies
(@andrew_davies)
Posts: 8
Active Member
Topic starter
 

That’s great!

Makes perfect sense. Many thanks for your help. Much appreciated.
Andrew

 
Posted : 04/08/2023 3:43 pm
Andrew_Davies
(@andrew_davies)
Posts: 8
Active Member
Topic starter
 

Hi

My apologies, I thought this made sense, but I have just been trying it out and can’t get it to work. I may not have explained it very well though.

The “Main” Airtable table will have a record with fields called COLUMN A, COLUMN B and COLUMN C

The values of these three fields, would indicate which columns to retrieve from the second Airtable table. (I am creating an HTML table with only 3 columns, and want to be able to set in the first Airtable table which 3 fields are to be retrieved)

The first search will only retrieve one record - with the names of the 3 fields that need to be retrieved from the second table.

I tried setting 3 variables (COL A, COL B, COL C) to the value of the fields to the first table - but of course I can’t then use the VALUES of the variable as fields names when creating the HTML.

Is it a dynamic variable I need? Not sure now if it is - apologies, I am not a programmer.

Thanks,
Andrew

 
Posted : 05/08/2023 6:39 pm
Andrew_Davies
(@andrew_davies)
Posts: 8
Active Member
Topic starter
 

Hi

Sorry to bump this thread, but I was wondering if you've had a moment to review my question? I'm uncertain if I misinterpreted your previous post or if my explanation isn't clear enough!

 
Posted : 09/08/2023 8:03 am
Darin_Patterson
(@darin_patterson)
Posts: 6
Active Member
 

Hi Andrew, I believe I understand your goal, and it presents an interesting challenge. I've put together an example scenario blueprint and some instructions. This use case does have a degree of complexity, but it's definitely achievable.

Here’s an overview of the scenario

Module 1 - Use Airtable Search Records to “Get Field Names from Main Table”
This should be quite straightforward.

Module 2 - Use Airtable Make an API Call to “Search Second Table”
This is the key step. You need to perform the search using this module to dynamically access the table information.
As you can see in the screenshot, the URL structure is essentially v0/{{baseID}}/{{tableName}}?maxRecords={{number}}
This achieves the same result as the Search Records module but provides a slightly different data structure that we can manipulate.

Module 3 - Use an Iterator to loop through each of the records returned from the previous module
This typically happens automatically with a Search Records module, but we are handling it manually here.

Module 4 - Use a Set Variable module to dynamically set the value of the fields.
Here, we utilize a get function to retrieve a specific field's value from a collection (in this case, the fields collection).

This scenario blueprint might be helpful. Remember to replace connection details and specific Base, table, and field names as needed. The blueprint also includes explanatory notes.
blueprint - 2023-08-10T140413.257.json (15.5 KB)

I hope this is useful! It was a good exercise for me regardless. Best regards.

 
Posted : 10/08/2023 8:06 pm
Andrew_Davies
(@andrew_davies)
Posts: 8
Active Member
Topic starter
 

That's fantastic! Thank you very much. This solution worked flawlessly. I had spent a considerable amount of time troubleshooting, and this was a great help.

Quick question: you utilized get() to match the variable. How does that compare to the map() function? From my understanding, I thought map() would be the correct choice, but I'm glad you highlighted this for me!

Thanks again – much appreciated.

Andrew

 
Posted : 10/08/2023 10:38 pm
Darin_Patterson
(@darin_patterson)
Posts: 6
Active Member
 

I'm pleased to hear that was successful. Concerning your inquiry about get() versus map():

map() is exclusively used with an array (a list of items). For instance, if you had a collection of books, you could find book titles where the Author is "Tolkien". Crucially, this operation could potentially yield multiple results (an array).

get() can be utilized with either an array or a collection. When applied to an array, it allows you to retrieve a specific element (such as the third book). When used with a collection, you can extract a particular value from that collection, like the title. This method always returns a single item.

 
Posted : 15/08/2023 4:02 pm
Share: