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.

Get data from a portal & get the record object?!

Featured Replies

So, we are hosting a web version of my company's application that works with a FileMaker database and recently we acquired a new server and for some reason(I don't know technical details, I'm not server-guy), the current version that works with FX doesn't work, so I was asked to make it work with the PHP API of FileMaker, which does work on that server.

Now I'm not a FileMaker programmer, so let's net get highly technicals with stuff I won't understand. I'm a web designer that never used much classes and object, which could explain my current confusion.

I'm trying to get records from the portals on specific layouts. I can already get portal-less information but I'm stuck on portals.

This is my code :

Page that shows retrieved information has this(and more) :

$session = new FMSession();

$dataSource = new SWData();

$infoSurvol = $dataSource->getSectionSA($recordNum);

$ptRisque = $dataSource->returnPortals();

Page that retrieves the information has this :

function returnPortals(){

return $this->portal1;

}

function getSectionSA() {

$findCommand = & $this->fm->newFindCommand ( LAYOUT_NAME );

$IDReq = func_get_arg(0);

$findCommand->addFindCriterion('-recid', $IDReq);

$result = $findCommand->execute ();

if(FileMaker::isError($result)) {

return null;

}

$records = $result->getRecords ();

$this->portal1 = $currentRecord->getRelatedSet(PORTAL_NAME);

return $this->recordsToArraySectionSA ( $records );

}

Now obviously, the problem is with the $currentRecord variable which isn't linked to anything right now. The documentation says :

Obtaining the portal records for a specific record

For a specific record object, use the getRelatedSet() method to retrieve an array of related records for a specific portal on that record.

Example

$relatedRecordsArray = $currentRecord->getRelatedSet('customers');

I was able to retrieve the name of the portals with another method, so I know it works. I just need help with this.

Thanks!

  • 2 weeks later...

Your code is from inside of a Class definition and without seeing the entire object it's a little difficult to tell what's going on.

Hopefully the following will help

$result contains a Filemaker_Result object.

the method getRecords() returns an Array of Filemaker_Record objects.

If you want to get each Filemaker_Record's Releated Set (also an Array of Filemaker_Record objects) your going to need to loop through the array and grab them.


$records = $result->getRecords ();

foreach ($records as $currentRecord){

	$relatedSet = $currentRecord->getRelatedSet(PORTAL_NAME);

	//do something with set because it will be overwritten 

	//on each iteration of the loop

	

}

PORTAL_NAME needs to be set to the String that identifies the related table reference.

$result->getRelatedSets(); returns the names of all related sets present in the result's layout.

  • 9 months later...

Yeh there's a little flaw in what you're doing:


function getSectionSA() {

$findCommand = $this->fm->newFindCommand ( LAYOUT_NAME );

$IDReq = func_get_arg(0);

$findCommand->addFindCriterion('-recid',$IDReq);

$result = $findCommand->execute ();

if(FileMaker::isError($ result)) {

return null;

}

$records = $result->getRecords ();

$this->portal1 = $currentRecord->getRelatedSet(PORTAL_NAME);

return $this->recordsToArraySectionSA ( $records );

}





Note above:





$records = $result->getRecords ();

$this->portal1 = $currentRecord->getRelatedSet(PORTAL_NAME);





What exactly is $currentRecord - it hasn't been set anywhere and you're trying to call a method on it.



There's a bit of faulty logic in the above... You retrieve MULTIPLE records... and then you are trying to retrieve and store a single portal on an instance of a single record? I.e. every record will have a different set of portal data, so it's a very weird thing to do.



If you want though, all you need to get this to work presuming there is nothing that is misconfigured is to define the $currentRecord variable prior to trying to call something on it.



e.g.



$records = $result->getRecords();

$currentRecord = $result->getFirstRecord();

$this->portal1 = $currentRecord->getRelatedSet(PORTAL_NAME);





... or just



$records = $result->getRecords();

$this->portal1 = $result->getFirstRecord()->getRelatedSet(PORTAL_NAME);

  • Author

Haha. That was a year ago. I had actually never noticed I had gotten a reply. Anyway, that was back when I didn't know how to gather data from portals, but I do now. Thanks for the help anyway.

Wow - no idea how that happened!!

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.