Pages::getMax($field)
Version 3.8
Get the greatest value
Version 3.8
Get the greatest value
Float
Get largest total amount from open invoices:
$max = $this->get('pages','invoice')->addWhere('status','Open')->getMax('total_amount');
This method is shorthand for:
$value = 0;
foreach ( $this->get('pages','Invoice')->hae('status=Open') as $Invoice ){
    if ( $Invoice->total_amount->isOver($value) ){
        $value = $Invoice->total_amount;
    }
}
Get Open Invoice that had the largest amount before discount:
$max = $this->get('pages','Invoice')
  ->addWhere('status','Open')
  ->getMax('total_amount*(100+discount_percent)/100');
DateField: The newest invoice date of open invoices:
$max = $this->get('pages','Invoice')
   ->addWhere('status','Open')
   ->getMax('invoice_date');
SelectionField: The latest status of customers Invoices:
$max = $this->get('pages','invoice')
   ->addWhere('customer', $customerId)
   ->getMax('status');