Page::isNew()

Version 3.8

Check if row is being saved for the first time

Return value

Bool

Full documentation

Set status value to 'New', if row is being saved for the first time and status is empty:

if ( $Order->isNew() ){
    $Order->status->setDefault('New');
}

Create or open a Invoice for customer. Set default values, if new.

$Invoice = $this->get('page','invoice')->findUnique(
    'customer' ,$customer->getId(),
    'status'   ,'New'
);

if ( $Invoice->isNew() ){
    $Invoice->invoice_date = $this->get('date');
    $Invoice->due_date     = $Invoice->invoice_date->getDate()->addDays(14);
}