define('NO_KEEP_STATISTIC', 'Y');
define('NO_AGENT_STATISTIC','Y');
define('NO_AGENT_CHECK', true);
define('PUBLIC_AJAX_MODE', true);
define('DisableEventsCheck', true);
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
if(!CModule::IncludeModule('crm')) die('error');
if(!CModule::IncludeModule('bizproc')) die('error');
$deal = '2594'; //id сделки
$documentType = array("crm", "CCrmDocumentDeal", "DEAL");
$documentId = array("crm", "CCrmDocumentDeal", 'DEAL_'.$deal);
$arDocumentStates = CBPDocument::GetDocumentStates( $documentType, $documentId);
//print_r($arDocumentStates);
if( !$deal || count($arDocumentStates) > 500 ){
die();
}
foreach ($arDocumentStates as $arDocumentState)
{
//print_r($arDocumentState['ID']);
$stopWorkflowId = $arDocumentState['ID'];
$arState = CBPStateService::GetWorkflowState($stopWorkflowId);
if (count($arState) > 0)
{
CBPDocument::TerminateWorkflow(
$stopWorkflowId,
$arState["DOCUMENT_ID"],
$arErrorsTmp
);
if (count($arErrorsTmp) > 0)
{
foreach ($arErrorsTmp as $e)
$errorMessage .= $e["message"].". ";
}
}
}
Остановить все бизнес-процессы документа битрикс24
В данном случае код останавливает все бп конкретной сделки. Битрикс24 бизнес-процессы остановить бп bitrix24 workflow b24 bizproc terminate