Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4027 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

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.

Posted

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.

Posted

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.

This topic is 4027 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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