API - Custom Search Cases

SEARCH BASICS

SEARCH CRITERIA

The body of a search request must include a search criteria. These criteria Ids are used in the "searchCriteria" property of the request body. The criteria are different depending on the field. For easier reference, the search criteria can be broken down into the following groups:

Group 1 - TEXT FIELDS

Text Fields can be searched with the following criteria:

- Equals, Not Equals, Starts With, Text Search

These criteria are represented as follows:

Equals:

{

"id": 0,

},

Not Equals

{

"id": 1,

},

Starts With

{

"id": 2,

},

Text Search

{

"id": 25,

}

Group 2 - DATE FIELDS

Date Fields can be searched with the following criteria:

( Note - X is number of days)

- Before, After, Between, Exactly, Newer than X, Older than X, Between X and Y, Current Week, Last Week, Month To Date, Last Month, Year To Date, Last Year

These criteria are represented as follows:

Before

{

"id": 6,

},

After

{

"id": 7,

},

Between

{

"id": 8,

},

Exactly

{

"id": 13,

},

Newer Than

{

"id": 12,

},

Older Than

{

"id": 11,

},

Between X and Y

{

"id": 18,

},

Current Week

{

"id": 19,

},

LastWeek

{

"id": 20,

},

Month To Date

{

"id": 21,

},

Last Month

{

"id": 22,

},

Year To Date

{

"id": 23,

},

Last Year

{

"id": 24,

}

Group 3 - DROPDOWN FIELDS

Dropdown fields can be searched with the following criteria:

- Equals, Not Equals, Select All

These criteria are represented as follows

Equals

{

"id": 0,

},

Not Equals

{

"id": 1,

},

Select All is the default and does not need to be specified in the search request body.

Group 4 - BOOLEAN FIELDS

Boolean fields (true or false) can be searched with the following criteria:

- Equals, Not Equals

These criteria are represented as follows:

Equals

{

"id": 0,

},

Not Equals

{

"id": 1,

},

Field Types

Field Types are specified using Ids, and are included in the body as "typeId"

These are the field types and their Ids:

CASE SEARCH

The following fields can be searched for cases:

Note the field name in parentheses - this will be used in our search request body

Group 1 Text Fields

Group 2 - Dates

Group 3 - Dropdown Fields

Group 4 - Boolean Fields

Examples

Here is the endpoint for a case search:

POST - https://{your api url}/api/cases/search

Text Field Search

Here is the body for a search with a text field.

We are searching the case number field where the text equals "2020-0318-01".

This value is added in the "model" property of the request body

Note that for "searchCriteria" we need to only provide the criteria id

Also note the "typeId" property is the field type as outlined above.


POST https://{api url}/api/cases/search


{

"StaticFields": [

{

"name": "CASE_NUMBER",

"typeId": 0,

"fieldName": "CaseNumber",

"searchCriterias": [

],

"searchCriteria": 0,

"model": "2020-0318-01"

}

],

"officeIds": [

608,

607

],

"orderBy": "Active",

"orderByAsc": false,

"PageSize": 25,

"peopleIds": [ ],

"PageNumber": 1,

"clientDate": "2020-03-19T20:57:27.372Z",

"clientTz": "America/New_York",

"timezoneOffset": 240,

"SavedSearchEntities": [ ],

"tags": [ ],

"IsSearchingInSublocations": false,

"DynamicFields": [ ]

}


Group 2 - Date Fields

Here is an example of a Date field search

We are searching a date of birth between the dates 01-01-2020 and 03-01-2020.

The "typeId" is now changed to the value corresponding to field type date

Note that "model" is the start date of the search and "toDate" is the to date.

Also, dates can be searched with just day, month, and year or can be a full date with time.

So, the "model" below could also be "2020-03-01T04:00:00.000Z"

POST - https://securelb.trackerproducts.com/api/cases/search


{


"StaticFields": [

{

"name": "GENERAL.CREATED_DATE",

"typeId": 2,

"fieldName": "CreatedDate",

"searchCriteriasType": 2,

"searchCriteria": 8,

"toDate": "2020-03-01T05:00:00.000Z",

"model": "2020-01-01T05:00:00.000Z"

}

],

"officeIds": [

608,

607

],

"orderBy": "Active",

"orderByAsc": false,

"PageSize": 25,

"peopleIds": [ ],

"PageNumber": 1,

"clientDate": "2020-03-19T21:19:07.310Z",

"clientTz": "America/New_York",

"timezoneOffset": 240,

"SavedSearchEntities": [ ],

"tags": [],

"IsSearchingInSublocations": false,

"DynamicFields": []

}


Here is a search of cases with a created date in the last year:

Note that the "model" is not needed for this search type.

POST - https://securelb.trackerproducts.com/api/cases/search

{


"StaticFields": [

{

"name": "GENERAL.CREATED_DATE",

"typeId": 2,

"fieldName": "CreatedDate",

"searchCriteriasType": 2,

"searchCriteria": 23,

"toDate": null,

"model": null

}

],

"officeIds": [

608,

607

],

"orderBy": "Active",

"orderByAsc": false,

"PageSize": 25,

"peopleIds": [ ],

"PageNumber": 1,

"clientDate": "2020-03-19T21:19:07.310Z",

"clientTz": "America/New_York",

"timezoneOffset": 240,

"SavedSearchEntities": [ ],

"tags": [],

"IsSearchingInSublocations": false,

"DynamicFields": []

}


Another type of date search is Newer Than and Older Than. This search uses the searchCriteria of 12, the model is the number of days, and the toDate is the current date. To search for all cases created within the last 30 days, the search would look like the following:

POST - https://securelb.trackerproducts.com/api/cases/search

{


"StaticFields": [

{

"name": "GENERAL.CREATED_DATE",

"typeId": 2,

"fieldName": "CreatedDate",

"searchCriteriasType": 2,

"searchCriteria": 12,

"toDate": "2020-06-09T04:00:00.000Z",

"model": 30

}

],

"officeIds": [

608,

607

],

"orderBy": "Active",

"orderByAsc": false,

"PageSize": 25,

"peopleIds": [ ],

"PageNumber": 1,

"clientDate": "2020-06-09T21:19:07.310Z",

"clientTz": "America/New_York",

"timezoneOffset": 240,

"SavedSearchEntities": [ ],

"tags": [],

"IsSearchingInSublocations": false,

"DynamicFields": []

}


Group 3 - Dropdown Fields

In order to search these fields you will first need to get the Ids that will be used as our "model" values

Case Offense types:

GET - https://securelb.trackerproducts.com/api/offensetypes



This will return an organization's offense types. Here is an example of the returned data:


[

{

"organizationOffenseTypeFollowUpDays": null,

"id": 158,

"name": "Accident",

"active": true,

"offenseTypeForms": null,

"organizations": [],

"autoDispositionSettings": [],

"customDropdownCategoryId": 1,

"customDropdownCategory": null

},

{

"organizationOffenseTypeFollowUpDays": null,

"id": 89,

"name": "Adoption",

"active": true,

"offenseTypeForms": null,

"organizations": [],

"autoDispositionSettings": [],

"customDropdownCategoryId": 1,

"customDropdownCategory": null

},


The important data here is the id - this will be used in the search.

To search for all cases with an offense type of "Accident", the search would look like the following:

POST - https://securelb.trackerproducts.com/api/cases/search

{


"StaticFields": [

{

"name": "CASE_OFFENSE_TYPE",

"typeId": 3,

"fieldName": "OffenseTypeId",

"searchCriteriasType": 1,

"dropdownEntities": {

"entity": "offenseTypes",

"options": {

"belongToOrganization": true

}

},

"searchCriterias": [ ],

"dropdownValues": [],

"searchCriteria": 0,

"model": 158

}

],

"officeIds": [

608,

607

],

"orderBy": "Active",

"orderByAsc": false,

"PageSize": 25,

"peopleIds": [ ],

"PageNumber": 1,

"clientDate": "2020-03-19T21:19:07.310Z",

"clientTz": "America/New_York",

"timezoneOffset": 240,

"SavedSearchEntities": [ ],

"tags": [],

"IsSearchingInSublocations": false,

"DynamicFields": []

}


"model" is offense type id


Dropdown fields can also be searched with not equals criteria.


To do so, just change searchCriteria to 1

Here is a search of all cases whose offense type is NOT 'Accident':

POST - https://securelb.trackerproducts.com/api/cases/search

{


"StaticFields": [

{

"name": "CASE_OFFENSE_TYPE",

"typeId": 3,

"fieldName": "OffenseTypeId",

"searchCriteriasType": 1,

"dropdownEntities": {

"entity": "offenseTypes",

"options": {

"belongToOrganization": true

}

},

"searchCriterias": [ ],

"dropdownValues": [],

"searchCriteria": 0,

"model": 158

}

],

"officeIds": [

608,

607

],

"orderBy": "Active",

"orderByAsc": false,

"PageSize": 25,

"peopleIds": [ ],

"PageNumber": 1,

"clientDate": "2020-03-19T21:19:07.310Z",

"clientTz": "America/New_York",

"timezoneOffset": 240,

"SavedSearchEntities": [ ],

"tags": [],

"IsSearchingInSublocations": false,

"DynamicFields": []

}