Jump to content

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


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

Recommended Posts

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

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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