October 9, 201213 yr 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?
October 9, 201213 yr 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?
October 11, 201213 yr 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