Documentation

GetService

CBPRuntimeService
public function GetService($name)(
 string name
);

This method returns a runtime service instance by its name.

Note: the following runtime services are available.

NameClassDescription
SchedulerServiceCBPSchedulerServiceServes to install an agent that will be executed within specified time and will send external events to the indicated workflow
StateServiceCBPStateServiceWorks with workflow status, saved in the database
TrackingServiceCBPTrackingServiceWorks with message recording to the log
TaskServiceCBPTaskServiceWorks with tasks
HistoryServiceCBPHistoryServiceWorks with document revision history
DocumentServiceCBPDocumentServiceDesigned to work with a document

Method parameters

ParameterDescription
nameService name

Returned value

Service class, inherited from CBPRuntimeService.

Examples

<?
// Save document $documentId history on behalf of $userId user
$runtime = CBPRuntime::GetRuntime();

$historyService = $runtime->GetService("HistoryService");
$documentService = $runtime->GetService("DocumentService");

$historyIndex = $historyService->AddHistory(
array(
"DOCUMENT_ID" => $documentId,
"NAME" => "New",
"DOCUMENT" => null,
"USER_ID" => $userId,
)
);

$arDocument = $documentService->GetDocumentForHistory($documentId, $historyIndex);
if (is_array($arDocument))
{
$historyService->UpdateHistory(
$historyIndex,
array(
"NAME" => $arDocument["NAME"],
"DOCUMENT" => $arDocument,
)
);
}
?>


© «Bitrix24», 2001-2024