Documentation

add

CTaskItem
public static function add(
	$arNewTaskData,
	$userId
);

This method returns a CTaskItem class instance.

Note: The method accepts an array of configuratison parameters and generates scripts, necessary to show file dialog. Static method.

Method parameters

ParameterDescription
$arNewTaskDataArray of fields with data for a task (TITLE, DESCRIPTION and etc.), list of fields - similarly to the CTasks::Add() method.
$userIdID of the user, on behalf of which the business logic rights and rules will be verified.

Examples

$task = new \Bitrix\Tasks\Item\Task(); // create a new entity instance (for example, new task, which is not yet available in the database)
$task = new \Bitrix\Tasks\Item\Task(0, 1); // create a new entity instance on behalf of user 1

Then

$task->title = 'hello';
$task->responsibleId = 4;

Or

$task['TITLE'] = 'hello';
$task['RESPONSIBLE_ID'] = 4;

Then

$result = $task->save();
if($result->isSuccess())
{
    print('EEEEEhaaaa!!!');
}
else
{
   print('Suck:');
   print_r($result->dump());
}


© «Bitrix24», 2001-2024