9 $documentType = \CBPDocument::unSignDocumentType($documentType);
14 return $this->deleteVariable($fieldId, $documentType);
16 return $this->deleteConstant($fieldId, $documentType);
20 'BIZPROC_CONTROLLER_GLOBALFIELD_MODE_NOT_DEFINED'
26 private function deleteVariable($variableId, $documentType):
array
28 $userId = (int)($this->getCurrentUser()->getId());
34 'BIZPROC_CONTROLLER_GLOBALFIELD_CANT_DELETE_VARIABLE_RIGHT'
44 'BIZPROC_CONTROLLER_GLOBALFIELD_NOT_EXISTS_VARIABLE'
54 'BIZPROC_CONTROLLER_GLOBALFIELD_CANT_DELETE_VARIABLE'
59 return [
'status' =>
'success'];
62 private function deleteConstant($constantId, $documentType):
array
65 $canDelete = \Bitrix\Bizproc\Workflow\Type\GlobalConst::canUserDelete($documentType,
$userId);
69 'error' => \Bitrix\Main\Localization\Loc::getMessage(
70 'BIZPROC_CONTROLLER_GLOBALFIELD_CANT_DELETE_CONSTANT_RIGHT'
75 $field = \Bitrix\Bizproc\Workflow\Type\GlobalConst::getById($constantId);
79 'error' => \Bitrix\Main\Localization\Loc::getMessage(
80 'BIZPROC_CONTROLLER_GLOBALFIELD_NOT_EXISTS_CONSTANT'
85 $result = \Bitrix\Bizproc\Workflow\Type\GlobalConst::delete($constantId);
89 'error' => \Bitrix\Main\Localization\Loc::getMessage(
90 'BIZPROC_CONTROLLER_GLOBALFIELD_CANT_DELETE_CONSTANT'
95 return [
'status' =>
'success'];
100 $documentType = \CBPDocument::unSignDocumentType($documentType);
104 return $this->upsertVariable($fieldId, $property, $documentType);
106 return $this->upsertConstant($fieldId, $property, $documentType);
110 'BIZPROC_CONTROLLER_GLOBALFIELD_MODE_NOT_DEFINED'
116 private function upsertVariable($variableId, $property, $documentType):
array
118 $userId = (int)($this->getCurrentUser()->getId());
124 'BIZPROC_CONTROLLER_GLOBALFIELD_CANT_UPSERT_VARIABLE_RIGHT'
130 $value = $this->getDefaultValue($documentType, $property,
$error);
133 return [
'error' =>
$error[0][
'message']];
135 $property[
'Default'] = $value ??
'';
136 $property[
'Name'] = trim($property[
'Name']);
138 $userId = (int)($this->getCurrentUser()->getId());
143 'error' =>
$result->getErrorMessages()[0],
147 return [
'status' =>
'success'];
150 private function upsertConstant($constantId, $property, $documentType):
array
153 $canUpsert = \Bitrix\Bizproc\Workflow\Type\GlobalConst::canUserUpsert($documentType,
$userId);
157 'error' => \Bitrix\Main\Localization\Loc::getMessage(
158 'BIZPROC_CONTROLLER_GLOBALFIELD_CANT_UPSERT_CONSTANT_RIGHT'
164 $value = $this->getDefaultValue($documentType, $property,
$error);
167 return [
'error' =>
$error[0][
'message']];
169 $property[
'Default'] =
$value ??
'';
170 $property[
'Name'] = trim($property[
'Name']);
173 $result = \Bitrix\Bizproc\Workflow\Type\GlobalConst::upsertByProperty($constantId, $property,
$userId);
177 'error' =>
$result->getErrorMessages()[0],
181 return [
'status' =>
'success'];
184 private function getDefaultValue($documentType, $property, &
$error)
187 $runtime = \CBPRuntime::GetRuntime();
188 $runtime->StartRuntime();
189 $documentService = $runtime->GetService(
"DocumentService");
190 $value = $documentService->GetFieldInputValue(
203 $documentType = \CBPDocument::unSignDocumentType($documentTypeSigned);
214 'BIZPROC_CONTROLLER_GLOBALFIELD_MODE_NOT_DEFINED'
static getMessage($code, $replace=null, $language=null)