A valid submission
When a Dispatch Task is created, a new report will also be created, so sufficient information must be provided in the "reports" section to simulate as if you had posted a new report to /reports, with report-fields included. The following is an example of a valid post to /dispatch-tasks:
{
"customId": "200019810",
"priority": "URGENT",
"client":50,
"report": {
"reportTemplate": 28,
"account": 50,
"reportFields": [
{"field": 29, "value": "12:30"},
{"field": 31, "value": "Something undesirable has occurred"},
{"field": 30, "value": "Interior Patrol"}
]
},
"startedOn": "20220331122600",
"taskType": 9,
"locationType": "ACCOUNT_ADDRESS"
}
Please note:
-
The client site ID (account) must be included in the root list of elements.
-
reportTemplate is not included in the root list of elements, only inside the report object.
-
The report object contains both the metadata for a new report, and also the list of fields that contain the report fields data
-
Each row of a reportField is comprised of the index number of the matching report-template-fields ID that defines the reportTemplate (in this example, it has ID 28), and a data value.
-
The value of each report-field must be appropriate to the type of field is defined in the parent report-template-fields. You'll need to lookup the /report-template-fields of a /report-templates to know what to expect. But you'll only be able to work with text/JSON data, no binaries. So if a template field normally contains a photo taken from the Guard Tour app, you won't be able to simulate a photo upload via the API.
To help expose the other dependencies like templates and template fields, here's what they look like (this is from an internal test environment, not your TrackTik portal):
Report Template and Fields (required)
Here’s an example of a Report Template (#28 from Innovation):
"data": {
"name": "Mobile Patrol Report",
"details": "Used to record the details of a completed Mobile Patrol task",
"tag": "",
"adminOnly": false,
"id": 28,
"defaultLanguage": "EN_US",
"translatable": true
}
Report-template-fields of Report Template 28:
"data": [
{
"reportTemplate": 28,
"label": "Arrival Time:",
"name": "f_29",
"type": "TIME",
"required": false,
"adminOnly": false,
"displayOrder": 100,
"extra": "",
"list": null,
"listItems": null,
"isDispatcherField": false,
"fieldTag": "",
"confidential": false,
"id": 29
},
{
"reportTemplate": 28,
"label": "Activity Performed:",
"name": "f_30",
"type": "LIST_MULTIPLE",
"required": false,
"adminOnly": false,
"displayOrder": 98,
"extra": "Interior Patrol\nExterior Patrol\nStationary Post\nLocation Inspection",
"list": [
"Interior Patrol",
"Exterior Patrol",
"Stationary Post",
"Location Inspection"
],
"listItems": [
"Interior Patrol",
"Exterior Patrol",
"Stationary Post",
"Location Inspection"
],
"isDispatcherField": false,
"fieldTag": "",
"confidential": false,
"id": 30
},
{
"reportTemplate": 28,
"label": "Narrative:",
"name": "f_31",
"type": "TEXTAREA",
"required": false,
"adminOnly": false,
"displayOrder": 96,
"extra": "",
"list": null,
"listItems": null,
"isDispatcherField": false,
"fieldTag": "",
"confidential": false,
"id": 31
},
...
etc.
Result of a Successful POST
The Dispatch Task that gets created from the example I shared (notice how the report element now shows the ID 4469 (from /reports) of the report that was auto-generated from having posted to /dispatch-tasks):
"data": {
"customId": "200019810",
"taskType": 9,
"priority": "URGENT",
"taskInstructions": "",
"startedOn": "2022-03-31T19:26:00+00:00",
"startDateTime": "2022-03-31T19:26:00+00:00",
"endedOn": null,
"endDateTime": null,
"plannedDurationInMinutes": null,
"reminderInMinutes": null,
"alarmOrganization": null,
"client": 50,
"account": 50,
"priceTier": null,
"status": "OPEN",
"active": "ACTIVE",
"assignedUser": null,
"assignedGroup": null,
"assignedVendor": null,
"reportTemplate": 28,
"report": 4469,
"workflowInstance": null,
"location": null,
"locationType": "ACCOUNT_ADDRESS",
"closedOn": null,
"id": 513
}
Example of what report-fields receive when report 4469 was created:
"data": [
{
"fieldTag": "",
"report": 4469,
"templateField": 29,
"value": {
"type": "text",
"value": "12:30"
},
"archived": false,
"id": 22247
},
{
"fieldTag": "",
"report": 4469,
"templateField": 30,
"value": {
"type": "array",
"value": [
"Interior Patrol"
]
},
"archived": false,
"id": 22248
},
{
"fieldTag": "",
"report": 4469,
"templateField": 31,
"value": {
"type": "text",
"value": "Something undesirable has occurred"
},
"archived": false,
"id": 22249
}
]
The parent /reports metadata created for the above fields:
"data": {
"reportTemplate": 28,
"timeZone": "America/Los_Angeles",
"account": 50,
"reportDateTime": "2022-04-04T08:42:24-07:00",
"submitTime": 1649086944,
"submittedOn": "2022-04-04T15:42:24+00:00",
"position": null,
"approvedOn": null,
"approvalDateTime": null,
"status": "PENDING",
"approvedBy": null,
"checkpoint": null,
"reportFlag": null,
"siteLocation": null,
"id": 4469
}