Skip to main content

Bitrix24 customization example - tasks list grouping by responsible person

One of our customers asked us to add a tasks list grouping by responsible person feature in Bitrix24. It is also required to be able to change a responsible person by simple dragging tasks to the appropriate group. This customer has self-hosted Bitrix24, so we were able to add a required functionality.


Tasks list in Bitrix24 may be sorted and filtered by responsible person, but the customer was not satisfied with these both options, he would like to have an ability to group tasks list by responsible person as additional grouping level.

First, we copy the component (tasks.list) in our own namespace. At the component code (component.php file) we find a place, where an array with sorting condition are formed. It is $arOrders array. We change the $arOrders array to make sort by responsible person ID in first priority:

$arOrder = array_merge(array("RESPONSIBLE_ID" => "ASC";), $arOrder);

For our surprise, after sorting, some tasks were placed in the wrong order: some tasks of one responsible person were mixed with tasks of another responsible person.

We began to clear up this problem and found such code in the CTask::GetList method:
foreach ($arOrder as $by => $order)
{
 ……
 switch ($by)
{
 ……
 case 'responsible_id':
 $arSqlOrder[] = " RESPONSIBLE_LAST_NAME ".$order." ";
 $needle = 'RESPONSIBLE_LAST_NAME';
   break;
 ……
 }
……
}

So, instead sorting by responsible person ID (this column are in the «b_tasks» table and available for sorting) Bitrix sorted our data by responsible person’s last name.

The system does not take into account the fact that the last name may be not specified. We have just such a case. All the responsible persons, whose tasks was "mixed", have not specified last names.

After we sorted the tasks in the required order, we also need some additional data about the responsible persons. In the code, that generates an array with tasks data, we find responsible person`s ID and make a request to select person's name, last name and login (we need to know login if the last name is not specified).

Next, we add request results to the $arResult array. Then we can work with component's templates.

Bitrix24 standard task list component has two views: list view and Gantt chart. It was necessary to change both. Both views already contained a grouping by projects. In accordance with the client's requirement, we add one more level of grouping - grouping by ID of the responsible person.

Customization of both component templates required us to significant changes in the Javascript code, we will not describe it in details, just show the final result (click images to view animation):




Comments

Popular posts from this blog

How to add a custom activity type in Bitrix24 CRM

During one of our recent self-hosted Bitrix24 implementations, we had the task of adding a new type of Activity to CRM - something between a Call Activity and a Visit Activity. The customer wanted this new Activity to be able to participate in CRM reports and filters. To begin with, it was necessary to add a link to a new Activity type in the CRM entity card. We found out that the crm.timeline component is responsible for the output of this part of the interface. In particular, its template.php contains a list of displayed links to case types. For example, for a call, something like: Accordingly, as we can see, this is a regular link with the data parameter item-item-id. So we can add ours, with our own unique data-item-id. As you can see, the href for the link is set as "#" - clicking on this link is processed by the JS code from the script.js of this component. Indeed, the BX.CrmTimelineMenuBar function is responsible for this.processItemSelection().

How to setup server for Bitrix24 on AWS EC2

How to сreate AWS Lambda Layer with Zeep Library

Python Zeep library designed to work with SOAP - services. Zeep is a pure-python module. However the lxml dependency does contain C code since it uses libxml2 and libxslt. So the Zeep library can not be deployed into the Lambda Layer without some tricks. In one of my Serverless projects, I needed to use this library, and I found such a way to deploy it into the Layer: