Если код нужен до смены статуса, то
OnSaleBeforeStatusOrderChange, если после - то
OnSaleStatusOrderChange\Bitrix\Main\EventManager::getInstance()->addEventHandler('sale', 'OnSaleStatusOrderChange', ['Handler', 'OnSaleStatusOrderChange']);
class Handler {
function OnSaleStatusOrderChange($event)
{
$parameters = $event->getParameters();
if ($parameters['VALUE'] === 'F')
{
/** @var \Bitrix\Sale\Order $order */
$order = $parameters['ENTITY'];
/**
*
* Your code is here
*
*/
}
return new \Bitrix\Main\EventResult(
\Bitrix\Main\EventResult::SUCCESS
);
}
}