Documentation

onBeforeTaskUpdate

Event is triggered before updating a task. The following is passed to the handler: task $id, updated $data fields (passed via link) and $copy, containing $data copy.

Response fields:

Field Description
FIELDS_BEFORE task fields before event. In case of no available task, this field will contain the value undefined.
FIELDS_AFTER task fields after event. In case of no available task fields, this field will contain the value undefined.
IS_ACCESSIBLE_BEFORE if the task was available (for reading) before event. Possible values:
  • Y (Yes) - yes;
  • N (No) - no;
  • undefined - undefined or such check wasn't performed.
IS_ACCESSIBLE_AFTER if task was available (for reading) after the event. Possible values:
  • Y (Yes) - yes;
  • N (No) - no;
  • undefined - undefined or such check wasn't performed.

Example

Example (event processing with anonymous function):

$eventManager = \Bitrix\Main\EventManager::getInstance();
$eventManager->addEventHandler('tasks', 'onBeforeTaskUpdate', function ($id, $data) {
   \CEventLog::Add([
         "SEVERITY" => "INFO",
        "AUDIT_TYPE_ID" => "DEBUG_TASKS_EVENTS",
        "MODULE_ID" => "main",
        "ITEM_ID" => $id,
        "DESCRIPTION" => json_encode($data),
   ]);

   // When you need to restrict changes, return false. If you need to print error message to the user, throw an exception via CMain
   if ( ... ) {
       $GLOBALS['APPLICATION']->ThrowException('Indicate error message here');

       return false;
   }
});

© «Bitrix24», 2001-2024