Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Getting portal records giving me a headache

Featured Replies

Greetings,

I am trying to show portal records from a related table with the PHP API, however it doesn't seem tob e working. The layout is created with the portal and showing data within FMPro, however the next piece of code doesn't return any rows:


<?php

// Tabs superiores de las pruebas

$findCommand =& $fm->newFindCommand('Pruebas');

$findCommand->addFindCriterion('UID_Evento', $_GET['uidevento']);

$result = $findCommand->execute();



// Get array of found records

$records = $result->getRecords();





// Print out found records



// Setup row count variable to alternate row background color

$tab = 1;



foreach ($records as $record) {

  

   $active_evento = $record->getField('UID_Prueba');

   echo "<div id=\"ui-tabs-" . $tab . "\">";

	  echo "<div class=\"layout\">";

	  

    //Widget de CLASIFICACIÓN RÁPIDA

   

    $findCommand =& $fm->newFindCommand('Carreras');

    $findCommand->addFindCriterion('UID_Prueba', $active_evento);

    $cresult = $findCommand->execute();

    $crecords = $cresult->getRecords();

	  

	   echo "<table class=\"source\">";

	   echo "<tr><th colspan=\"3\">CLASIFICACIÓN RÁPIDA</th></tr>";

	   echo "<tr>";

	   echo "<th>#</th>";

	   echo "<th>Dorsal</th>";

	   echo "<th>Nombre</th>";

	   echo "</tr>";

	   $relatedSet = $crecords->getRelatedSet('Portal_Clasif');

	   foreach ($relatedSet as $relatedSets) {

	   echo "<tr>";

	   echo "<td>" . $relatedSets->getField('Carreras::Rank.Calc') . "</td>";

	   echo "<td>" . $relatedSets->getField('Carreras::Number') . "</td>";

	   echo "<td>" . $relatedSets->getField('Carreras::Name._.Apellido') . "</td>";

	   echo "</tr>";  

	   }

	   echo "</table>";

	 

	  echo "</div>";

	  echo "</div>";

	  $tab++;

}

?>

I am trying to avoid straight Find requests since they provoke an error when there are no records found and I want the layout to be shown regardless of finding records or not. I read somewhere that getRelatedSet did not cause this behaviour and it was allowed to have empty portals, but I am not able to even pull the data before beginning filtering to test that behavior.

As you can see from the code, it is first pulling records from another table with has a relation to the "child" table with the UIDs, as to show only the records that related to the event and then to the Prueba. It works well with a findCommand.

Has anyone had success doing something like this or knows how to get it achieved?

Well, you can always trap for the no records found if a Find works otherwise...

And if the portal is on the layout for the original search, why do you need to run another searhc instead of just pulling the portal records?

  • Author

Well, you can always trap for the no records found if a Find works otherwise...

And if the portal is on the layout for the original search, why do you need to run another searhc instead of just pulling the portal records?

Aye, ended up making an if statement on no records found and nested the following search as the error, which is working well.

There are two searches because first it pulls information from the "mother" table, Pruebas(Events), to pull the title (it comes with a GET from a listed search in the navigation bar, this would be the content) and then it uses that uidevent to link the correct records together. Then it does a search for the child records, which would be the participants in that Event.

It's a shame I wasn't capable of getting portals to work, could've saved many headaches, and nesting the searches by trapping the no matching records looks a bit like doing things wrong.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.