API - Edit a Case

v100 has a change in the case model:

CaseOfficerId field is now CaseOfficerIds and accepts an array of user ids

First, we will do a get request to retrieve the case object:

https://secure.trackerproducts.com/api/cases/getByNumber?value=(casenumber)


This will return a json object for the case:

{

"id": 2933671,

"caseNumber": "2018-0521-01",

"caseOfficerIds": [

12659

],

"caseOfficers": [

"Mike Singleton"

],

"offenseTypeId": 74,

"offenseType": "Alcohol Related",

"offenseDescription": "Public Intoxication",

"offenseLocation": "Newport, KY, USA",

"offenseDate": "2018-05-21T04:00:00Z",

"followUpDate": null,

"active": true,

"officeId": 1,

"officeName": "1 Office",

"creatorId": 1,

"creator": "Jack 3176D103FF Sparrow",

"createdDate": "2018-05-21T10:06:56.692Z",

"organizationId": 1,

"organizationName": "Tracker Products",

"items": [

4932605

],

"nextItemId": "2",

"media": null,

"mediaAmount": 0,

"rootMediaFolderId": 153738,

"formData": null,

"formDataAmount": 0,

"notes": null,

"notesAmount": 0,

"tags": [


],

"tagsAmount": 0,

"peopleAmount": 0,

"tasksAmount": 0,

"historiesAmount": 0,

"closedDate": null,

"reviewDate": "2018-09-13T04:00:00Z",

"reviewDateNotes": "",

"isRestricted": false,

"permissionAmount": 0,

"permissions": null,

"isForbidden": false

}


2. Now you can use the returned case object, make any changes to the case, and then submit update to the following endpoint using the case id in a PUT request: - Note - formData in the above GET is null, for the update to process correctly, your request should have an empty array.


https://secure.trackerproducts.com/api/cases/2933671

Here is the body of the request: {

"id": 2933671,

"caseNumber": "2018-0521-01",

"caseOfficerIds": [

12659

],

"caseOfficers": [

"Mike Singleton"

],

"offenseTypeId": 74,

"offenseType": "Alcohol Related",

"offenseDescription": "Public Intoxication at a shopping mall",

"offenseLocation": "Newport, KY, USA",

"offenseDate": "2018-05-21T04:00:00Z",

"followUpDate": null,

"active": true,

"officeId": 1,

"officeName": "1 Office",

"creatorId": 1,

"creator": "Jack Sparrow",

"createdDate": "2018-05-21T10:06:56.692Z",

"organizationId": 1,

"organizationName": "Tracker Products",

"items": [

4932605

],

"nextItemId": "2",

"media": null,

"mediaAmount": 0,

"rootMediaFolderId": 153738,

"formData": [


],

"formDataAmount": 0,

"notes": null,

"notesAmount": 0,

"tags": [


],

"tagsAmount": 0,

"peopleAmount": 1,

"tasksAmount": 0,

"historiesAmount": 14,

"closedDate": null,

"reviewDate": "2018-09-13T04:00:00Z",

"reviewDateNotes": "",

"isRestricted": false,

"permissionAmount": 0,

"permissions": null,

"isForbidden": false

}


There is no returned content. A successful update will return a status code 204 No Content.



Case update to add custom form data

1. you must retrieve custom form data.


Here is the endpoint to retrieve available custom forms:

Note there are 4 options for retrieving forms - All, Cases, Items, People

(see the request header below)


https://securelb.trackerproducts.com/api/forms?formType=Cases


Here are the results:

[

{

"id": 34,

"name": "Case Status (Sys Template)",

"schema": "{\"fields\":[{\"type\":\"selectlist\",\"name\":\"field3377\",\"displayName\":\"Case Status\",\"options\":[{\"value\":\"1\",\"text\":\"Active\",\"$$hashKey\":\"object:19459\"},{\"value\":\"2\",\"text\":\"Closed\",\"$$hashKey\":\"object:19460\"},{\"value\":\"3\",\"text\":\"Review\",\"$$hashKey\":\"object:19461\"}],\"value\":\"1\",\"$$hashKey\":\"object:19444\",\"$_invalid\":false,\"$_displayProperties\":true},{\"type\":\"selectlist\",\"name\":\"field9715\",\"displayName\":\"Disposition Review\",\"options\":[{\"value\":\"1\",\"text\":\"Six Months\",\"$$hashKey\":\"object:2806\"},{\"value\":\"2\",\"text\":\"One Year\",\"$$hashKey\":\"object:2807\"},{\"value\":\"3\",\"text\":\"Five Years\",\"$$hashKey\":\"object:2808\"}],\"value\":\"2\",\"$$hashKey\":\"object:2786\",\"$_invalid\":false,\"$_displayProperties\":true}],\"$_invalid\":false}",

"organizationId": 1,

"organization": null,

"modelTypeId": 4,

"modelType": null,

"locked": false,

"isSharedForm": true,

"categoryForms": null,

"offenseTypeForms": null

},


{

"id": 759,

"name": "Legal Level",

"schema": "{\"fields\":[{\"type\":\"radiobuttonlist\",\"name\":\"field733\",\"displayName\":\"What is legal level?\",\"options\":[{\"value\":\"3\",\"text\":\"Going to trial\",\"$$hashKey\":\"object:8464\"},{\"value\":\"2\",\"text\":\"No trial\",\"$$hashKey\":\"object:8463\"},{\"value\":\"1\",\"text\":\"Thrown Out\",\"$$hashKey\":\"object:8462\"}],\"value\":null,\"$$hashKey\":\"object:8456\",\"$_displayProperties\":true,\"$_invalid\":false,\"validation\":{\"messages\":{}}}]}",

"organizationId": 1,

"organization": null,

"modelTypeId": 4,

"modelType": null,

"locked": false,

"isSharedForm": false,

"categoryForms": null,

"offenseTypeForms": null

},


{

"id": 830,

"name": "state lab form",

"schema": "{\"fields\":[{\"type\":\"text\",\"name\":\"field2866\",\"displayName\":\"Textbox\",\"$$hashKey\":\"object:6914\"},{\"type\":\"email\",\"name\":\"field2868\",\"displayName\":\"Email\",\"$$hashKey\":\"object:6921\"}]}",

"organizationId": 1,

"organization": null,

"modelTypeId": 4,

"modelType": null,

"locked": false,

"isSharedForm": false,

"categoryForms": null,

"offenseTypeForms": null

},


{

"id": 911,

"name": "Precinct2",

"schema": "{\"fields\":[{\"type\":\"selectlist\",\"name\":\"field8538\",\"displayName\":\"Select List\",\"options\":[{\"value\":\"3\",\"text\":\"East\",\"$$hashKey\":\"object:7258\"},{\"value\":\"1\",\"text\":\"North\",\"$$hashKey\":\"object:7256\"},{\"value\":\"\",\"text\":\"Select an option\",\"$$hashKey\":\"object:7255\"},{\"value\":\"2\",\"text\":\"South\",\"$$hashKey\":\"object:7257\"},{\"value\":\"4\",\"text\":\"West\",\"isNew\":true,\"$$hashKey\":\"object:7345\"}],\"value\":\"\",\"$$hashKey\":\"object:7248\",\"$_displayProperties\":true,\"$_invalid\":false,\"validation\":{\"messages\":{}}}]}",

"organizationId": 1,

"organization": null,

"modelTypeId": 4,

"modelType": null,

"locked": false,

"isSharedForm": false,

"categoryForms": null,

"offenseTypeForms": null

}

]



The below request will add "Precint2" form to the case

An example PUT request will look like the following:


https://securelb.trackerproducts.com/api/cases/2933671


Note- within formData.data double quotes are escaped with a backward slash


{

"id": 2933671,

"caseNumber": "2018-0521-01",

"caseOfficerIds": [

12659

],

"caseOfficers": [

"Mike Singleton"

],

"offenseTypeId": 74,

"offenseType": "Alcohol Related",

"offenseDescription": "Public Intoxication at a train station, again",

"offenseLocation": "Newport, KY, USA",

"offenseDate": "2018-05-21T04:00:00Z",

"followUpDate": null,

"active": true,

"officeId": 1,

"officeName": "1 Office",

"creatorId": 1,

"creator": "Jack Sparrow",

"createdDate": "2018-05-21T10:06:56.692Z",

"organizationId": 1,

"organizationName": "Tracker Products",

"items": [

4932605

],

"nextItemId": "2",

"media": null,

"mediaAmount": 0,

"rootMediaFolderId": 153738,

"formData": [

{

"formId": 911,

"formName": "Precinct2",

"data": "{\"field8538\":\"2\"}",

"entityId": "2933671",

"dateFields": [


]

}

],

"formDataAmount": 0,

"notes": null,

"notesAmount": 0,

"tags": [


],

"tagsAmount": 0,

"peopleAmount": 1,

"tasksAmount": 0,

"historiesAmount": 18,

"closedDate": null,

"reviewDate": "2018-09-13T04:00:00Z",

"reviewDateNotes": "",

"isRestricted": false,

"permissionAmount": 0,

"permissions": null,

"isForbidden": false

}


Adding tags to a case is a similar process.

Here is an endpoint to retrieve all available tags for an organization:

This is a GET request

https://securelb.trackerproducts.com/api/tags


This returns an array of tags avaialble


[

{

"itemsCount": 0,

"casesCount": 2,

"id": 2388,

"name": "Test Tag",

"organizationId": 1,

"organization": null,

"active": true

},

{

"itemsCount": 0,

"casesCount": 1,

"id": 2389,

"name": "Test Tag 2",

"organizationId": 1,

"organization": null,

"active": true

},

{

"itemsCount": 0,

"casesCount": 1,

"id": 2390,

"name": "Test Tag 3",

"organizationId": 1,

"organization": null,

"active": true

},

{

"itemsCount": 0,

"casesCount": 0,

"id": 2391,

"name": "Test Tag 4",

"organizationId": 1,

"organization": null,

"active": true

}


]


Here is a PUT request for a case adding the Tag, "Test Tag" to the case


https://securelb.trackerproducts.com/api/cases/2933671


{

"id": 2933671,

"caseNumber": "2018-0521-01",

"caseOfficerIds": [

12659

],

"caseOfficers": [

"Mike Singleton"

],

"offenseTypeId": 74,

"offenseType": "Alcohol Related",

"offenseDescription": "Public Intoxication at a train station, again",

"offenseLocation": "Newport, KY, USA",

"offenseDate": "2018-05-21T04:00:00Z",

"followUpDate": null,

"active": true,

"officeId": 1,

"officeName": "1 Office",

"creatorId": 1,

"creator": "Jack Sparrow",

"createdDate": "2018-05-21T10:06:56.692Z",

"organizationId": 1,

"organizationName": "Tracker Products",

"items": [

4932605

],

"nextItemId": "2",

"media": null,

"mediaAmount": 0,

"rootMediaFolderId": 153738,

"formData": [

{

"id": "5b2cec7a185c8a62b89ad500",

"active": true,

"entityId": 2933671,

"formId": 911,

"formName": "Precinct2",

"dateFields": [


],

"data": "{\"field8538\":\"2\"}",

"organizationId": 1,

"officeId": 1,

"visibilityId": 0,

"route": "formdata",

"reqParams": null,

"restangularized": true,

"fromServer": true,

"parentResource": {

"route": "cases",

"parentResource": null,

"id": "2933671"

},

"restangularCollection": false

}

],

"formDataAmount": 1,

"notes": null,

"notesAmount": 0,

"tags": [

{

"tagModelId": 2388,

"name": "Test Tag"

}

],

"tagsAmount": 0,

"peopleAmount": 1,

"tasksAmount": 0,

"historiesAmount": 20,

"closedDate": null,

"reviewDate": "2018-09-13T04:00:00Z",

"reviewDateNotes": "",

"isRestricted": false,

"permissionAmount": 0,

"permissions": null,

"isForbidden": false

}￿￿￿

Possible Error Scenarios


In this section, we will look at errors returned during a case POST.

Auto Disposition Error


This error occurs when auto disposition is turned on for an organization and the organization does not have auto disposition settings for all offense types.

Here is an example of the error I will receive when attempting to do a PUT request for a case with offense type Bomb Threat:


{

"autoDispoErrors": [

"Offense Type and Auto Disposition Settings are not found"

]

} )

This message is the result of missing auto disposition settings for the offense type, Bomb Threat.


To resolve, first get the auto disposition settings for the organization.

GET https://{api url}/api/autoDisposition/settings/


{

"isAutoDispositionOn": true,

"officeAutoDispositionReviewers": [

{

"officeId": 1,

"officeName": "1 Office, LLC",

"generalTaskFromUserId": 1,

"generalTaskFromUserGroupId": null,

\ "isDefault": true,

"isGeneralTaskFromUser": true

},

{

"officeId": 175,

"officeName": "175 Office",

"generalTaskFromUserId": null,

"generalTaskFromUserGroupId": 76,

"isDefault": false,

"isGeneralTaskFromUser": false

}

],

"settings": [

{

"id": 1,

"active": true,

"daysToFollowUp": 1000,

"organizationId": 1,

"organization": null,

"offenseTypeId": 1,

"offenseType": {

"organizationOffenseTypeFollowUpDays": null,

"id": 1,

"name": "Other",

"active": true,

"offenseTypeForms": null,

"organizations": [],

"autoDispositionSettings": [],

"customDropdownCategoryId": 1,

"customDropdownCategory": null

}

},

{

"id": 2,

"active": true,

"daysToFollowUp": 1000,

"organizationId": 1,

"organization": null,

"offenseTypeId": 2,

"offenseType": {

"organizationOffenseTypeFollowUpDays": null,

"id": 2,

"name": "Arson",

"active": true,

"offenseTypeForms": null,

"organizations": [],

"autoDispositionSettings": [],

"customDropdownCategoryId": 1,

"customDropdownCategory": null

}

},

{

"id": 3,

"active": true,

"daysToFollowUp": 1000,

"organizationId": 1,

"organization": null,

"offenseTypeId": 3,

"offenseType": {

"organizationOffenseTypeFollowUpDays": null,

"id": 3,

"name": "Assault",

"active": true,

"offenseTypeForms": null,

"organizations": [],

"autoDispositionSettings": [],

"customDropdownCategoryId": 1,

"customDropdownCategory": null

}

},

{

"id": 0,

"active": false,

"daysToFollowUp": 0,

"organizationId": 0,

"organization": null,

"offenseTypeId": 178,

"offenseType": {

"organizationOffenseTypeFollowUpDays": null,

"id": 178,

"name": "Bomb Threat",

"active": true,

"offenseTypeForms": null,

"organizations": [],

"autoDispositionSettings": [],

"customDropdownCategoryId": 1,

"customDropdownCategory": null

}

},



The response is rather long - I have abbreviated to include the pertinent information. Note that for offense type Bomb Threat id is 0, days to follow up is 0, organizationId is 0. We need to add settings for this offense type.

To accomplish this, the api user token must belong to a user with orgAdmin permissions.

PUT https://{api url}/api/autoDisposition/settings/

{

"isAutoDispositionOn": true,

"officeAutoDispositionReviewers": [

{

"officeId": 1,

"officeName": "1 Office, LLC",

"generalTaskFromUserId": 1,

"generalTaskFromUserGroupId": null,

\ "isDefault": true,

"isGeneralTaskFromUser": true

},

{

"officeId": 175,

"officeName": "175 Office",

"generalTaskFromUserId": null,

"generalTaskFromUserGroupId": 76,

"isDefault": false,

"isGeneralTaskFromUser": false

}

], "settings": [

{

"id": 0,

"active": false,

"daysToFollowUp": 100,

"organizationId": 1,

"organization": null,

"offenseTypeId": 178,

"offenseType": {

"organizationOffenseTypeFollowUpDays": null,

"id": 178,

"name": "Bomb Threat",

"active": true,

"offenseTypeForms": null,

"organizations": [],

"autoDispositionSettings": [],

"customDropdownCategoryId": 1,

"customDropdownCategory": null

}

}

],

"listPermissionGroupIds": [

1,68,69,1387,1388, 1389

],

"createPermissionGroupIds": [

1,68,69,1387,1389

],

"updatePermissionGroupIds": [

43,68,69,1387,1389

]

}



Some Notes: