A
A
aleks_kuper2021-09-30 13:18:10
Bitrix24
aleks_kuper, 2021-09-30 13:18:10

How to display the names of tasks linked to a deal?

Good afternoon.
There is a need to display in the notification a list of task names that were set in a particular deal.
Manually starts a business process that performs this action.
I was able to display all existing tasks, but I can't figure out how to filter them by deal.
Below is the code we currently have. Tasktest is a BP template variable, I save the selected names into it and send a notification to the user.

\Bitrix\Main\Loader::IncludeModule("tasks");
//\Bitrix\Main\Loader::includeModule('crm');
//CModule::IncludeModule("tasks")

$tasktest = $this->GetVariable("Tasktest"); 

$arOrder = array();
$arFilter = array();
$arSelect = array("TITLE");

if (\Bitrix\Main\Loader::includeModule('crm')) {
     $res = CTasks::GetList($arOrder, $arFilter, $arSelect); 
}
$array=[];
while($tasktest = $res->fetch()){
      $array[] = $tasktest;

 }

$this->SetVariable("Tasktest",$array);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2021-10-11
@gromdron

I was able to achieve the output of all existing tasks,

Remember that the filter is performed based on the rights of the current user, which means that another user will have a different result. To remove this behavior, look in the CHECK_PERMISSIONS code for flags and see how they work.
how to filter them by the link to the deal.

The link to the deal is stored in the UF_CRM_TASK field, stored as a combination of an entity letter and an identifier, separated by an underscore.
For example, a task that has a connection with deal 123 will have D_123 in this field

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question