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

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


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

Recommended Posts

Posted

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...
Posted

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...
Posted

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);

Posted

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.

This topic is 5584 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.