- Модуль: bizproc
- Путь к файлу: ~/bitrix/modules/bizproc/lib/controller/globalfield.php
- Класс: BitrixBizprocControllerGlobalField
- Вызов: GlobalField::upsertConstant
private function upsertConstant($constantId, $property, $documentType): array
{
$userId = (int)($this->getCurrentUser()->getId());
$canUpsert = BitrixBizprocWorkflowTypeGlobalConst::canUserUpsert($documentType, $userId);
if (!$canUpsert)
{
return [
'error' => BitrixMainLocalizationLoc::getMessage(
'BIZPROC_CONTROLLER_GLOBALFIELD_CANT_UPSERT_CONSTANT_RIGHT'
),
];
}
$error = [];
$value = $this->getDefaultValue($documentType, $property, $error);
if ($error)
{
return ['error' => $error[0]['message']];
}
$property['Default'] = $value ?? '';
$property['Name'] = trim($property['Name']);
$userId = (int)($this->getCurrentUser()->getId());
$result = BitrixBizprocWorkflowTypeGlobalConst::upsertByProperty($constantId, $property, $userId);
if (!$result->isSuccess())
{
return [
'error' => $result->getErrorMessages()[0],
];
}
return ['status' => 'success'];
}