API Client
Get Accounts Audit Logs

This is a basic example of retrieving a list of model Audit logs using 1CRM API.

//Get Accounts audit logs
$model = $client->model('Account');
$result = $model->getAuditLogs(null, 0, 2); // fetch no more than 2 records, starting from the beginning
printf("There are %d records in total\n", $result->totalResults());
echo json_encode($result->getRecords(), JSON_PRETTY_PRINT), "\n";

Output:

1 There are 1162 records in total
2 [
3  {
4  "id": "d1b32ea5-44c3-8fb8-aa14-5ed50426146f",
5  "created_by_user": "",
6  "created_by": null,
7  "date_created": "2020-06-01 13:39:08",
8  "parent": "",
9  "parent_id": "aabdeac3-5a0c-577b-b32a-5d653164cb4c",
10  "field_name": "phone_office",
11  "data_type": "phone",
12  "before_value_string": null,
13  "after_value_string": "+1-999-99-9999",
14  "before_value_text": null,
15  "after_value_text": null,
16  "erased": "0",
17  "source": null
18  },
19  {
20  "id": "760202ef-79ec-c9f5-3505-5ec28073a175",
21  "created_by_user": "admin",
22  "created_by": "1",
23  "date_created": "2020-05-18 12:31:03",
24  "parent": "",
25  "parent_id": "52600b8b-bc77-1980-687b-5ec28069bd95",
26  "field_name": "assigned_user_id",
27  "data_type": "id",
28  "before_value_string": null,
29  "after_value_string": "1",
30  "before_value_text": null,
31  "after_value_text": null,
32  "erased": "0",
33  "source": null
34  }
35 ]
//Get a list of audit logs belonging to specified Account record
$account_id = '87056d90-0fbd-1202-f074-5c9b250f15af';
$model = $client->model('Account');
$result = $model->getAuditLogs($account_id, 0, 2); // fetch no more than 2 records, starting from the beginning
printf("There are %d records in total\n", $result->totalResults());
echo json_encode($result->getRecords(), JSON_PRETTY_PRINT), "\n";

Output:

1 There are 6 records in total
2 [
3  {
4  "id": "877f6492-8efe-2cc3-7c5a-5c9b250724a4",
5  "created_by_user": "admin",
6  "created_by": "1",
7  "date_created": "2019-03-27 07:24:57",
8  "parent": "",
9  "parent_id": "87056d90-0fbd-1202-f074-5c9b250f15af",
10  "field_name": "assigned_user_id",
11  "data_type": "id",
12  "before_value_string": null,
13  "after_value_string": "1",
14  "before_value_text": null,
15  "after_value_text": null,
16  "erased": "0",
17  "source": null
18  },
19  {
20  "id": "8780dcdf-373a-d5b1-19d5-5c9b25297b19",
21  "created_by_user": "admin",
22  "created_by": "1",
23  "date_created": "2019-03-27 07:24:57",
24  "parent": "",
25  "parent_id": "87056d90-0fbd-1202-f074-5c9b250f15af",
26  "field_name": "name",
27  "data_type": "name",
28  "before_value_string": null,
29  "after_value_string": "1CRM Systems Corp.",
30  "before_value_text": null,
31  "after_value_text": null,
32  "erased": "0",
33  "source": null
34  }
35 ]