Not logged in - Login

Custom Form Data

This page will outline how to update a case by adding custom form data, and it will also give an example of creating a case with custom form data.

Case With No Custom From Data

Updating custom form data can be easily accomplished using just the API.

The first scenario is one where the case does not contain the custom form. Here is the endpoint to get a case by its id:
GET https://securelb.trackerproducts.com/api/cases/2933785
This returns the case information:
{
"id": 2933785,
"caseNumber": "2018-1023-01",
"caseOfficerId": 1,
"caseOfficer": "Jack Sparrow",
"offenseTypeId": 3,
"offenseType": "Assault",
"offenseDescription": "Test",
"offenseLocation": "Newport, KY, USA",
"offenseDate": "2018-10-23T04:00:00Z",
"followUpDate": null,
"active": true,
"officeId": 1,
"officeName": "1 Office",
"creatorId": 17663,
"creator": "Mike Singleton",
"createdDate": "2018-10-23T19:10:08.945Z",
"organizationId": 1,
"organizationName": "Tracker Products",
"items": [],
"nextItemId": "1",
"media": null,
"mediaAmount": 0,
"rootMediaFolderId": 194120,
"formData": null,
"formDataAmount": 0,
"notes": null,
"notesAmount": 0,
"tags": [],
"tagsAmount": 0,
"peopleAmount": 1,
"tasksAmount": 0,
"historiesAmount": 2,
"closedDate": null,
"reviewDate": null,
"reviewDateNotes": "",
"isRestricted": false,
"permissionAmount": 0,
"permissions": null,
"isForbidden": false
}


Note that the formData field is null

The next information that will be necessary is the custom form that you would like to add to this case.
Here is the endpoint for retrieving custom forms:

Note there are 4 options for retrieving forms - All, Cases, Items, People (see the request header below)


GET https://securelb.trackerproducts.com/api/forms?formType=Cases
Here is a sample of the returned data :
{
"id": 921,
"name": "Test Custom Case Form",
"schema": "{\"fields\":[{\"type\":\"text\", \"name\":\"field6459\",\"displayName\":\"Test Custom Form Text
Box\",\"$$hashKey\":\"object:9707\",\"$_displayProperties\":true,\"$_invalid\":false,\"validation\":{\"messages\":{}}}]}",
"organizationId": 1,
"modelTypeId": 4,
"locked": false,
"isSharedForm": false,
"isActive": true
}


Reading json data can be tiresome - here are a few tips:
- using any text editor remove the forward slash which is used to escape the double quotes
- format the json using a tool such as: http://jsonviewer.stack.hu/


Here is the custom form data after I have removed the escape characters:
{
"id": 921,
"name": "Test Custom Case Form",
"schema": "{"fields":[{"type":"text",
                     "name":"field6459",

                     "displayName":"TestCustomFormTextBox",
                     "$$hashKey":"object: 9707",
                     "$_displayProperties":true,
                     "$_invalid":false,
                     "validation":{"messages":{}}}]}",
"organizationId": 1,
"modelTypeId": 4,
"locked": false,
"isSharedForm": false,
"isActive": true
}
The important pieces of data here are:
the form id (921)
the field name (field6459)
field type (text)

Example JSON For Adding A Custom Form To A Case


To add this custom form to an existing we will use the following JSON:
{
"id": 2933785,
"caseNumber": "2018-1023-01",
"caseOfficerId": 1,
"caseOfficer": "Jack Sparrow",
"offenseTypeId": 3,
"offenseType": "Assault",
"offenseDescription": "Test",
"offenseLocation": "Newport, KY, USA",
"offenseDate": "2018-10-23T04:00:00Z",
"followUpDate": null,
"active": true,
"officeId": 1,
"officeName": "1 Office",
"creatorId": 17663,
"creator": "Mike Singleton",
"createdDate": "2018-10-23T19:10:08.945Z",
"organizationId": 1,
"organizationName": "Tracker Products",
"items": [],
"nextItemId": "1",
"media": null,
"mediaAmount": 0,
"rootMediaFolderId": 194120,
"formData": [ {
"entityId": 2933785,
"formId": 921,
"data": "{\"field6459\":\"Test custom data entry\"}",
"dateFields": [ ]
}
],

"formDataAmount": 0,
"notes": null,
"notesAmount": 0,
"tags": [],
"tagsAmount": 0,
"peopleAmount": 1,
"tasksAmount": 0,
"historiesAmount": 2,
"closedDate": null,
"reviewDate": null,
"reviewDateNotes": "",
"isRestricted": false,
"permissionAmount": 0,
"permissions": null,
"isForbidden": false
}


Note that the double quote must be escaped with a forward slash


The process for adding the custom form to a new case is very similar. The main difference to note is that the entityId field will be 0 for a new case (this value is the case id which the system will assign after the case is created).
Here is my json for adding a case with the custom form data:


{
"offenseDate": "2018-10-23T04:00:00.000Z",
"active": true,
"offenseDescription": "Stole my lunch money",
"offenseTypeId": 4,
"formData": [
{
"entityId": 0,
"formId": 921,
"data": "{\"field6459\":\"Test custom data entry\"}",
"dateFields": [ ]
}
],
"tags": [

],
"reviewDateNotes": "",
"caseNumber": "2018-1023-03",
"checkInProgress": false,
"caseOfficerId": 1,
"offenseLocation": "Newport, KY, USA"
}


Now if we do a GET for this case, we will see that the custom data is now part of the case details:
https://securelb.trackerproducts.com/api/cases/2933787


{
"id": 2933787,
"caseNumber": "2018-1023-03",
"caseOfficerId": 1,
"caseOfficer": "Jack 3176D103FF Sparrow",
"offenseTypeId": 4,
"offenseType": "Burglary",
"offenseDescription": "Stole my lunch money",
"offenseLocation": "Newport, KY, USA",
"offenseDate": "2018-10-23T04:00:00Z",
"followUpDate": null,
"active": true,
"officeId": 1,
"officeName": null,
"creatorId": 1,
"creator": "Jack 3176D103FF Sparrow",
"createdDate": "2018-10-23T20:06:08.7428568Z",
"organizationId": 1,
"organizationName": null,
"items": [],
"nextItemId": "1",
"media": [],
"mediaAmount": 0,
"rootMediaFolderId": 194122,
"formData": [
{
"id": "5bcf7f30185c8a8354659607",
"active": true,
"entityId": 2933787,
"formId": 921,
"formName": "Test Custom Case Form",
"dateFields": [],
"data": "{\"field6459\":\"Test custom data entry\"}",
"organizationId": 1,
"officeId": 1,
"visibilityId": 0
}
],
"formDataAmount": 1,
"notes": [],
"notesAmount": 0,
"tags": [],
"tagsAmount": 0,
"peopleAmount": 0,
"tasksAmount": 0,
"historiesAmount": 0,
"closedDate": null,
"reviewDate": null,
"reviewDateNotes": "",
"isRestricted": false,
"permissionAmount": 0,
"permissions": null,
"isForbidden": false
}