API Client
Get list of project tasks in a project

Most records in 1CRM have other related recors linked to them. For example, Contact can have a number of related accounts, and Project can have multiple project tasks. To fetch a list of related records, use the Model::getRelated() method. It returns an instance of ListResult class.

Model::getRelated(), similar to Model::getList(), accepts 'fields', 'filters' and 'order' options - see other examples.

$model = $client->model('Project');
$project_id = '79ae14b8-5f03-cf4a-c986-5aa7988a6119';
$fields = ['name', 'date_due', 'status'];
$link_name = 'project_tasks';
$result = $model->getRelated($project_id, $link_name, ['fields' => $fields], 0, 5);
printf("There are %d project tasks in total\n", $result->totalResults());
echo json_encode($result->getRecords(), JSON_PRETTY_PRINT), "\n";

Output:

1 There are 11 project tasks in total
2 [
3  {
4  "name": "Conceptualization",
5  "date_due": "2018-03-08",
6  "status": "In Progress",
7  "id": "8ac8c990-99cb-9933-b58e-5aa798ff7bfd",
8  "_display": "Conceptualization"
9  },
10  {
11  "name": "Brainstorming",
12  "date_due": "2018-03-04",
13  "status": "In Progress",
14  "id": "ade37d77-2884-1d80-414e-5aa7980944c0",
15  "_display": "Brainstorming"
16  },
17  {
18  "name": "Specifications",
19  "date_due": "2018-03-08",
20  "status": "In Progress",
21  "id": "aff39b25-f394-33d6-9d48-5aa79885ad61",
22  "_display": "Specifications"
23  },
24  {
25  "name": "Engineering",
26  "date_due": "2018-03-23",
27  "status": "Deferred",
28  "id": "b1cae5c5-fdfe-91cc-a023-5aa7985e429a",
29  "_display": "Engineering"
30  },
31  {
32  "name": "Design",
33  "date_due": "2018-03-14",
34  "status": "Pending Input",
35  "id": "b36e1762-35f0-3570-4d4c-5aa7987eb4f0",
36  "_display": "Design"
37  }
38 ]