diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index fc624f726a7..1553c9f3e53 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6173,15 +6173,23 @@ abstract class CommonObject } } - if (! $error && ! $notrigger) { + if (! $error) + { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + } - if (!$notrigger) { - // Call triggers - $result=$this->call_trigger(strtoupper(get_class($this)).'_CREATE',$user); - if ($result < 0) { $error++; } - // End call triggers - } + if (! $error) + { + $result=$this->insertExtraFields(); + if ($result < 0) $error++; + } + + if (! $error && ! $notrigger) + { + // Call triggers + $result=$this->call_trigger(strtoupper(get_class($this)).'_CREATE',$user); + if ($result < 0) { $error++; } + // End call triggers } // Commit or rollback