- Модуль: bizproc
- Путь к файлу: ~/bitrix/modules/bizproc/classes/general/document.php
- Класс: CBPDocument
- Вызов: CBPDocument::addDocumentToHistory
static function addDocumentToHistory($parameterDocumentId, $name, $userId)
{
[$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentId);
if ($moduleId <> '')
CModule::IncludeModule($moduleId);
if (!class_exists($entity))
return false;
$runtime = CBPRuntime::GetRuntime();
$runtime->StartRuntime();
$historyService = $runtime->GetService("HistoryService");
$documentService = $runtime->GetService("DocumentService");
$userId = intval($userId);
$historyIndex = $historyService->AddHistory(
array(
"DOCUMENT_ID" => $parameterDocumentId,
"NAME" => "New",
"DOCUMENT" => null,
"USER_ID" => $userId,
)
);
$arDocument = $documentService->GetDocumentForHistory($parameterDocumentId, $historyIndex);
if (!is_array($arDocument))
return false;
$historyService->UpdateHistory(
$historyIndex,
array(
"NAME" => $name,
"DOCUMENT" => $arDocument,
)
);
return $historyIndex;
}