• I was successfully retrieving a value from Airtable using shortcode: [apr field=”Country”]

    I had to change the field Country in Airtable to be link to Countries table. Now instead of the country name, it is showing some system id starting with rc… I did Ctrl+Z in Airtable until the field was normal text field and it started to work again.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chester McLaughlin

    (@chetmac)

    See the section on ‘Related Records’ on this page:
    https://www.ads-software.com/plugins/airpress/

    Thread Starter peachperfectweddings

    (@peachperfectweddings)

    Thanks for prompt reply. I have indeed looked into Related Records, though to actually retrieve data from related record. In this specific case I am retrieving all values from one table, but it fails for the field “Country”, when it is changed to be Foreign Key (linking field).

    But if I can make the related records work, it would help me enormously.

    Table 1: SuppliersVenues, PK field Venue ID, FK field Country
    Table 2: Countries, PK field Country, I want to output field Slug from table Countries

    I have virtual field connected to Table 1 and can successfully retrieve values from it (except the FK field).

    I used your example with Events and Locations, but in my case I am fetching related record only one level deep, so it is simpler:

    [apr_populate field="Country" relatedTo="Countries"]
    [airfield name="Country|Slug"]

    But when I try it, it outputs:
    [airfield name=”Country|Slug”]

    I also use ?fresh just in case.

    Am I missing something?

    I also tried following PHP code:

    <?php
    $currentPost = get_post();
    $venue = $currentPost ->AirpressCollection[0];
    $linked_field = "Country";
    $linked_table = "Countries";
    $venue->populateRelatedField($linked_field, $linked_table);
    
    echo $venue[0]["Country"][0]["Slug"];
    ?>

    And it fails: the page is not displayed at all and a few lines of error text are shown.

    However, I use a plugin called Insert PHP Code Snippet to insert PHP and it worked OK for simple code like:

    <?php
    $currentPost = get_post();
    $venue = $currentPost ->AirpressCollection[0];
    echo $venue["Name"];
    echo "<br />";
    ?>

    (I was not able to use your example with directly using $post variable, so I had to call get_post() to get $post first).

    Any advise?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Retrieving a field value fails after changing Airtable field TYPE (not name)’ is closed to new replies.