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

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

Recommended Posts

  • Newbies
Posted

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

 

 

Posted

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.

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