Documentation

addChildTaskByTemplate

CTaskItem[]
CTaskItem::addChildTasksByTemplate(
          $templateId, 
          $parameters = array()
)

The method adds subtasks from the template.

Returned value

This method returns an array of created [link=32362]CTaskItem[/link] class instances.

Method parameters

Parameter Description
$templateId Template ID.
$parameters Array of subtask parameters .

Example of use

CModule::IncludeModule('tasks');

$taskId = 1373;
$executiveUserId = $GLOBALS['USER']->GetId();
$templateId = 6;

// creating task instance to attach new subtasks to
$taskInstance = CTaskItem::getInstance($taskId, $executiveUserId);

$createdSubtasks = $taskInstance->addChildTasksByTemplate($templateId, array(
   // transfer some parameters
   'BEFORE_ADD_CALLBACK' => function(&$fields){
       print('will be created:'.PHP_EOL);
       print_r($fields);
    },
));

print_r($createdSubtasks);


© «Bitrix24», 2001-2024
Up