Documentation

GetService

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

This method returns a runtime service instance by its name. The following runtime services are available.

NameClassDescription
SchedulerServiceCBPSchedulerServiceWorks to install an agent which will be executed within specified time and will send external event to an indicated workflow
StateServiceCBPStateServiceDesigned to handle workflow status, saved in the database
TrackingServiceCBPTrackingServiceDesigned to record messages to log
TaskServiceCBPTaskServiceDesigned to work with tasks
HistoryServiceCBPHistoryServiceDesigned to work with document revision history
DocumentServiceCBPDocumentServiceDesigned to work with document

Method parameters

ParameterDescription
nameService name

Returned value

Returns service class, inherited from CBPRuntimeService.

Examples

<?
// Save document $documentId history on behalf of user $userId
$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