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.

Featured Replies

  • Newbies

Hello everyone.

 

Im quite new to filemaker php api and also php but starting to get the hang of it.

 

what i need help with is that when i try to get the id of a portal record i get a php 500 error.

 

if i comment out the part i add in it works fine but when i leave them in i get the error.

 

the reason i need to get the id of the portal record is cause i use supercontainer to store my document and their linked by the id document.

<?php
		
	require_once 'Filemaker.php';
	
	include 'includes/dbaccess_asset.php';
		
	if(isset($_GET['search']) and $_GET['search'] != '') 
	{
		$search = $_GET['search'];
		$request =& $fm->newFindCommand('IWP_Documents_List');
		$request->addFindCriterion('ID_Product', $search);;
	} 
	else 
	{		
		$search = '';		
		$request =& $fm->newFindAllCommand('IWP_Documents_List');
	}
	
	if(isset($_GET['sortby']) and $_GET['sortby'] != '')
	{
		$request->addSortRule($_GET['sortby'], 1);
	}
	
	$result = $request->execute();
	
	$portal_records = $record->getRelatedSet('T06_DOCUMENTS');
	
	$records = $result->getRecords();
			
	# loop through records compiling row html
	$rows = '';
	foreach ($records as $record)
	{	
		$rows .= '<div style="background-color:#EEEEEE;margin-bottom:5px;padding:4px;">';
		$rows .= '<div style="width:100px;float:left; font-family:Arial; color:#1385c6; font-size:12px;">'.$record->getField('ID_Product'). '</div>';
		$rows .= '<div style="width:160px;float:left; font-family:Arial; color:#1385c6; font-size:12px;"><a href="http://195.***.**.**:8020/SuperContainer/Files/Documents/ISO8124/'.$portal_records->getField('T06_DOCUMENTS::ID_Document').'?style=readonly">Download ISO 8124</a></div>';		
		$rows .= '<div style="width:160px;float:left; font-family:Arial; color:#1385c6; font-size:12px;"><a href="http://195.***.**.**:8020/SuperContainer/Files/Documents/EN71/'.$portal_records->getField('T06_DOCUMENTS::ID_Document').'?style=readonly">Download EN 71</a></div>';
		$rows .= '<div style="width:160px;float:left; font-family:Arial; color:#1385c6; font-size:12px;"><a href="http://195.***.**.**:8020/SuperContainer/Files/Documents/ASTM/'.$portal_records->getField('T06_DOCUMENTS::ID_Document').'?style=readonly">Download ASTM</a></div>';
		$rows .= '<div style="width:160px;float:left; font-family:Arial; color:#1385c6; font-size:12px;"><a href="http://195.***.**.**:8020/SuperContainer/Files/Documents/JSFL/'.$portal_records->getField('T06_DOCUMENTS::ID_Document').'?style=readonly">Download JSFL</a></div>';
		$rows .= '<div style="width:160px;float:left; font-family:Arial; color:#1385c6; font-size:12px;"><a href="http://195.***.**.**:8020/SuperContainer/Files/Documents/Others/'.$portal_records->getField('T06_DOCUMENTS::ID_Document').'?style=readonly">Download Others</a></div>';
		$rows .=  '  <div style="clear:both;"></div>';
		$rows .=  '</div>';
	}
?>
<form action="Testrep.php" method="get">
	<p>
    	<label style="font-size: 12px; font-family: arial; color: #1385C6;">Find a report</label><br />
        <input type="text" name="search" value="<?php echo $search ?>" />
        <button type="submit" value="search">Search</button>
	</p>
</form>

<div style="margin-bottom:5px;padding:4px;">

<div style="width:105px;float:left; font-family:Arial; color:#1385c6; font-size:12px;"><a href="Testrep.php?search=<?php echo $search ?>&sortby=ID_Product">item No.</a></div>
<div style="width:160px;float:left; font-family:Arial; color:#1385c6; font-size:12px;">ISO 8124</div>
<div style="width:160px;float:left; font-family:Arial; color:#1385c6; font-size:12px;">EN 71</div>
<div style="width:160px;float:left; font-family:Arial; color:#1385c6; font-size:12px;">ASTM</div>
<div style="width:160px;float:left; font-family:Arial; color:#1385c6; font-size:12px;">JSFL</div>
<div style="width:160px;float:left; font-family:Arial; color:#1385c6; font-size:12px;">Others</div>

<div style="clear:both;"></div>
<?php echo $rows; ?>

if you dont understand what am trying to achive just tell me and ill try to explain it better.

It looks like you are trying to access an array as though it were an object. If you view the contents of the $portal_records variable after setting it, I think it will be easier for you to understand. Here is one way to do that:

$portal_records = $record->getRelatedSet('T06_DOCUMENTS');

// for debugging only! view contents of a variable
echo '<pre>';
print_r($portal_records);
echo '</pre>';

So, if you add a nested foreach statement to loop through $portal_records, I think that will solve your problem.

I usually ignore the getRelatedRecords step and just have the php access a layout based on the related TO that the portal is derived from.

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.