//  [java]
	public function updateExtraField($key, $trigger = null, $userused = null)
	{
		global $conf, $langs, $user;

		if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
			return 0;
		}

		if (empty($userused)) {
			$userused = $user;
		}

		$error = 0;

		if (!empty($this->array_options) && isset($this->array_options["options_".$key])) {
			// Check parameters
			$langs->load('admin');
			require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
			$extrafields = new ExtraFields($this->db);
			$extrafields->fetch_name_optionals_label($this->table_element);

			$value = $this->array_options["options_".$key];

			$attributeType     = $extrafields->attributes[$this->table_element]['type'][$key];
			$attributeLabel    = $extrafields->attributes[$this->table_element]['label'][$key];
			$attributeParam    = $extrafields->attributes[$this->table_element]['param'][$key];
			$attributeRequired = $extrafields->attributes[$this->table_element]['required'][$key];
			$attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$key];

			// Similar code than into insertExtraFields
			if ($attributeRequired) {
				$mandatorypb = false;
				if ($attributeType == 'link' && $this->array_options["options_".$key] == '-1') {
					$mandatorypb = true;
				}
				if ($this->array_options["options_".$key] === '') {
					$mandatorypb = true;
				}
				if ($mandatorypb) {
					$langs->load("errors");
					dol_syslog("Mandatory field 'options_".$key."' is empty during update and set to required into definition of extrafields");
					$this->errors[] = $langs->trans('ErrorFieldRequired', $attributeLabel);
					return -1;
				}
			}

			//dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG);
			//dol_syslog("attributeType=".$attributeType, LOG_DEBUG);

			if (!empty($attrfieldcomputed)) {
				if (!empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) {
					$value = dol_eval($attrfieldcomputed, 1, 0);
					dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG);
					$this->array_options["options_".$key] = $value;
				} else {
					$this->array_options["options_".$key] = null;
				}
			}

			switch ($attributeType) {
				case 'int':
					if (!is_numeric($value) && $value != '') {
						$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
						return -1;
					} elseif ($value === '') {
						$this->array_options["options_".$key] = null;
					}
					break;
				case 'double':
					$value = price2num($value);
					if (!is_numeric($value) && $value != '') {
						dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
						$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
						return -1;
					} elseif ($value === '') {
						$this->array_options["options_".$key] = null;
					}
					//dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG);
					$this->array_options["options_".$key] = $value;
					break;
				/*case 'select':	// Not required, we chosed value='0' for undefined values
					 if ($value=='-1')
					 {
						 $this->array_options[$key] = null;
					 }
					 break;*/
				case 'price':
					$this->array_options["options_".$key] = price2num($this->array_options["options_".$key]);
					break;
				case 'date':
				case 'datetime':
					if (empty($this->array_options["options_".$key])) {
						$this->array_options["options_".$key] = null;
					} else {
						$this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]);
					}
					break;
				case 'boolean':
					if (empty($this->array_options["options_".$key])) {
						$this->array_options["options_".$key] = null;
					}
					break;
				/*
				case 'link':
					$param_list = array_keys($attributeParam['options']);
					// 0 : ObjectName
					// 1 : classPath
					$InfoFieldList = explode(":", $param_list[0]);
					dol_include_once($InfoFieldList[1]);
					if ($InfoFieldList[0] && class_exists($InfoFieldList[0]))
					{
						if ($value == '-1')	// -1 is key for no defined in combo list of objects
						{
							$new_array_options[$key] = '';
						} elseif ($value) {
							$object = new $InfoFieldList[0]($this->db);
							if (is_numeric($value)) $res = $object->fetch($value);	// Common case
							else $res = $object->fetch('', $value);					// For compatibility

							if ($res > 0) $new_array_options[$key] = $object->id;
							else {
								$this->error = "Id/Ref '".$value."' for object '".$object->element."' not found";
								$this->db->rollback();
								return -1;
							}
						}
					} else {
						dol_syslog('Error bad setup of extrafield', LOG_WARNING);
					}
					break;
				*/
			}

			$this->db->begin();

			$linealreadyfound = 0;

			// Check if there is already a line for this object (in most cases, it is, but sometimes it is not, for example when extra field has been created after), so we must keep this overload)
			$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".((int) $this->id);
			$resql = $this->db->query($sql);
			if ($resql) {
				$tmpobj = $this->db->fetch_object($resql);
				if ($tmpobj) {
					$linealreadyfound = $tmpobj->nb;
				}
			}

			if ($linealreadyfound) {
				if ($this->array_options["options_".$key] === null) {
					$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = null";
				} else {
					$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'";
				}
				$sql .= " WHERE fk_object = ".((int) $this->id);
			} else {