Help

Re: Script for filtering

1082 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Yamen_Rabadi
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi there .
I have two related tables : Companies and Contacts . Lets say for example :
Company A have Contact 1 and Contact 2
Company B have Contact 3 and Contact 4
Company C have Contact 5 and Contact 5
I want help to make a button with script on the Companies table that when I click it (on Company B for example) , it will go to a view of the Contacts table and automatically filter the contacts to show only contacts 3 and 4 .
Can you help me please ? Thank you

5 Replies 5

Welcome to the community, @Yamen_Rabadi! :grinning_face_with_big_eyes: This can be done without a script. Create a {Filter} checkbox field in the [Companies] table. In the [Contacts] table, create a lookup field that retrieves the value of that {Filter} field, then make a new view that only shows records where that lookup field contains checks.

Thank you Justin for your support and swift reply . Please be patient with me :slightly_smiling_face: i did not understand what is the {filter} checkbox field .

That’s just a checkbox field named “Filter” (I write it like {Filter} just to be clear that it’s a field).

Thank you :slightly_smiling_face: it worked .
But I need a simple script attched to a button on the Companies table that will take me direct to the Contacts table to that Contact table filtered checkbox view . Also at that Contact table filtered view , I need a button to take me back directly to the related company in the Companies table .

Thank you for your support . Really appreciate it :slightly_smiling_face:

Buttons that run scripts can’t change the active view/table. They only run the desired script in the appropriate app in the sidebar.

To open a specific view, the button would need to be one that opens a URL. If you’re running Airtable in a browser, you can copy the view’s URL from the navigation bar and add it to the button field configuration.

If you do that, you’ll open the expanded view of that company record on top of the main grid view. If that’s what you want, you could do something similar with a button field that opens a URL. This time, though, you’ll need to build the URL to add the record ID at the end. To do this, add a formula field in the [Companies] table that outputs the record ID using the RECORD_ID() function. Over in the [Contacts] table, use a lookup field to bring this ID over. I’ll call this formula field {Company Record ID}. You can then use it in a formula in the button field. Begin with the URL for the desired company view, and then concatenate the record ID. Something like this:

"https://airtable.com/appAAAAAAAAAAAAAA/tblTTTTTTTTTTTTTT/viwVVVVVVVVVVVVVV/" & {Company Record ID}

If you don’t want to open the company record directly, then skip the new fields and just put the desired company view URL into a button in the [Contacts] table, similar to what you did previously to make a button in the [Companies] table that changed to the filtered contacts view.

As long as you’re using Airtable in a browser and not one of the standalone apps, these buttons will allow you to switch back and forth within a single tab.