use Bitrix\Main\Loader;
Loader::includeModule('crm');
$obActivities = CCrmActivity::GetList(
[],
[
'OWNER_TYPE_ID' => CCrmOwnerType::ResolveID('CONTACT'),
'COMPLETED' => 'N',
'CHECK_PERMISSIONS' => 'N'
],
false,
false,
[
'ID'
]
);
while ($arActivity = $obActivities->Fetch()) {
CCrmActivity::Update(
$arActivity['ID'],
[
'COMPLETED' => 'Y'
],
false
);
}