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.

How to get the value of summary field in a found set in PHP

Featured Replies

  • Newbies

Hello,

 

I'm new to FM and Custom Web Publishing. I'm playing with PHP and I after various days of searching I can't figure how can get the value of a summary field in a found set.

 

This is the code I'm actually using, this code get the value of one record, not the value of all found set.

 

(Excuse my English....)

 

"Total Sales" is the summary field.

 

Any help please?

 

Thank you very much.

 

$findCommand = $fm->newFindAnyCommand("MyLayout");
$findCommand->addFindCriterion("Year", "2018");
#$findCommand->setRange(0, 1);
$result = $findCommand->execute();

if(FileMaker::isError($result)){
	echo($result->getMessage());
	return;
	
}

$record = current($result->getRecords());

$totalsales = $record->getField("Total Sales");

 

 

On first examination, the code looks ok, but recreating the query reveals that "newFindAnyCommand" doesn't produce a result for Summary fields. It also doesn't make sense to find just one record and then add an additional FindCriterion.

Suggest using  "newFindCommand" instead.

For what is worth, I have always just generated summary totals on the fly during foreach loops, like this:

$records = $result->getRecords();

foreach ($records as $record) {

     $totalSales = $totalSales + $record->getField("Sales");

 }

echo $totalSales;

 

Hope that helps.

  • Author
  • Newbies

Thank you very much for your help.

 

i will try it.

 

 

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.