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.

getting info from two layouts

Featured Replies

  • Newbies

I'm sure this is simple, but for some reason I am stuck:

I am trying to get records from one layout, then use the info to get the record ID from another layout. I get the records from the first layout fine, but it stops working at the second getRecords() request? Did I need to reset the DB to all records or something else....I;m not entirely used to how FM interacts with PHP.

Here is my code:

...

$fm = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);

$test = $_POST['test'];

$COPY_LOCATIONID = $test;

$request = $fm->newFindCommand('COPY');

$request->addFindCriterion( 'COPY_LOCATIONID', $COPY_LOCATIONID);

$result = $request->execute();

$records = $result->getRecords();

$rows = '';

foreach ($records as $record) {

$rows .=$record->getField('ITEM::title');

}

$rows2 = '';

foreach ($records as $record) {

$rows2 .=$record->getField('CREATOR::creator');

}

$rows3 = '';

foreach ($records as $record) {

$rows3 .=$record->getField('PUBLISHER::publisher');

}

$rows4 = '';

foreach ($records as $record) {

$rows4 .=$record->getField('ITEM::issued');

}

$recDBCN = '';

foreach ($records as $record) {

$recDBCN .=$record->getField('ITEM::identifier');

}

$fm2 = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);

$request2 =$fm2->newFindCommand('ITEM');

$request2->addFindCriterion('identifier', $recDBCN);

$result2 = $request2->execute();

$records2 = $result2->getRecords();

//$recId = '';

//foreach ($records as $record) {

//$recId .=$record->getRecordId();

//}

$userData ="bookTi=".$rows;

$userData .="&bookAu=".$rows2;

$userData .="&bookPub=".$rows3;

$userData .="&copyR=".$rows4;

$userData .="&recId=".$recDBCN;

print $userData;

?>

Make sure the layout you are using has on it all the fields that you want to access.

Hope that helps.

James

First, you need to add error checking after both of your $request->execute() calls. This should tell you what is going on.


$result = $request->execute();

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

	echo 'Error: (' . $result->getCode() . ') ' . $result->getMessage() . "n";

	exit;

}

$records = $result->getRecords();



and



$result2 = $request2->execute();

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

	echo 'Error: (' . $result2->getCode() . ') ' . $result2->getMessage() . "n";

	exit;

}

$records2 = $result2->getRecords();





Second, I'm not sure what you're going for by concatenating all of a field's values across the returned record set to a single string.  If your query is designed to always return one and only one record you can access the record this way



$records = $result->getRecords();

$title = $records[0]->getField('ITEM::title');





If you do need to loop through the records there's no need to do it more than once



$rows = '';

$rows2 = '';

$rows3 = '';

$rows4 = '';

$recDBCN = '';

foreach ($records as $record) {

	$rows .=

	$rows2 .=$record->getField('CREATOR::creator');

	$rows3 .=$record->getField('PUBLISHER::publisher');

	$rows4 .=$record->getField('ITEM::issued');

	$recDBCN .=$record->getField('ITEM::identifier');

}

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.