API Client
Retrieving list of related records

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

$model = $client->model('Contact');
$result = $model->getRelated('7eba2a01-6cb6-f38c-d4c2-5a8fc2def9d2', 'accounts' [], 0, 2);
echo $result->totalResults(), "\n";
echo json_encode($result->getRecords(), JSON_PRETTY_PRINT);
1 2
2 [
3  {
4  "balance": "3222.22",
5  "balance_payable": "0",
6  "is_supplier": "0",
7  "credit_limit": null,
8  "purchase_credit_limit": null,
9  "currency_id": "-99",
10  "id": "80ed9241-3612-f3cd-ee4d-5a8fc236c860",
11  "credit_limit_usd": null,
12  "currency": "US Dollar: $",
13  "exchange_rate": "1",
14  "purchase_credit_limit_usd": null,
15  "name": "360 Vacations",
16  "_display": "360 Vacations"
17  },
18  {
19  "balance": "0",
20  "balance_payable": "0",
21  "is_supplier": "0",
22  "credit_limit": null,
23  "purchase_credit_limit": null,
24  "currency_id": "-99",
25  "id": "94b8157d-aff9-023f-3745-5a8fc278192f",
26  "credit_limit_usd": null,
27  "currency": "US Dollar: $",
28  "exchange_rate": "1",
29  "purchase_credit_limit_usd": null,
30  "name": "ABC FUEL CO",
31  "_display": "ABC FUEL CO"
32  }
33 ]

Model::getRelated() accepts same options as Model::getList() - see Retrieving list of records