diff --git a/core/dbobject.class.php b/core/dbobject.class.php index e4b8a9ff4b..75d45e7734 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -742,6 +742,30 @@ public function SetIfNull($sAttCode, $value) } } + /** + * Helper to copy a value only if the target is currently undefined + * + * Call Copy() only of the internal representation of the target attribute is null. + * + * @api + * @see Copy() + * @see SetIfNull()) + * + * @param string $sDestAttCode + * @param string $sSourceAttCode + * + * @return bool true if copy was successfull or was not performed because target attribute isn't null + * + * @throws \CoreException + * @throws \CoreUnexpectedValue + * @throws \Exception + */ + public function CopyIfNull($sDestAttCode, $sSourceAttCode) + { + $this->SetIfNull($sDestAttCode, $this->Get($sSourceAttCode)); + return true; + } + /** * Helper to set a value that fits the attribute max size *