Skip to content

Search Criteria

Search Criteria can be used to retrieve get list response of an entity based on specific conditions. Here are some samples for search criteria.

Fields

field refers to input entity fields for criteria construction.

Example

{
  "field": "created_time",
  "condition": "greater than",
  "value": "1488451440000"
}

Condition

Conditions are the operators for criteria construction.

Supported Conditions

Description Operator Operator Short Hand
Equals is =, eq
Not Equal is not !=, neq
Greater than greater than gt
Greater than or Equal greater or equal gte
Less than lesser than lt
Less than or Equal lesser or equal lte
Range between
Not in Range not between
Starts with starts with
Ends with ends with
Contains contains
Not Contains not contains

Example

{
  "field": "created_time",
  "condition": "greater than",
  "value": "1488451440000"
}

In the above example the greater than is the operator which refers to greater than symbol (>).

Comparison – (field > value)

Value/Values

Value/Values provided in the value field depends on the data type of the field name and the operator used in the criteria.

  1. In case of multiple values, values key needs to be used.
  2. In case of single value, value key needs to be used.

Example (Value)

{
  "field": "created_time",
  "condition": "greater than",
  "value": "1488451440000"
}

In the above example the value of the above criteria is Long which is based on the field created_time.

Example (Values)

{
  "field": "group.name",
  "condition": "is",
  "values": [
    "Network",
    "Printer Problem"
  ]
}

In the above example the possible values of the above criteria are Network and Printer Problem which is mentioned within an array.

Children

The children criteria key holds sub criteria or nested criteria.

Example

{
  "list_info": {
    "row_count": 100,
    "search_criteria": {
      "field": "status",
      "condition": "is",
      "value": {
        "id": "100000000000008033",
        "name": "Open"
      },
      "children": [
        {
          "field": "created_time",
          "condition": "greater than",
          "value": "1488451440000",
          "logical_operator": "AND"
        }
      ]
    }
  }
}

The conditional rule for the above search criteria is given below,
Criteria – (status = 'Open' AND (created_time > 1488451440000))

1) A&B – A(and)B

The following list info object will retrieve all the pending requests under group “Network”

{
  "list_info": {
    "row_count": 15,
    "search_criteria": [
      {
        "field": "group.name",
        "condition": "is",
        "values": [
          "Network"
        ]
      },
      {
        "field": "status.in_progress",
        "condition": "is",
        "logical_operator": "and",
        "values": [
          true
        ]
      }
    ]
  }
}

The following list info object will retrieve all the “Open” requests under group “Network”

{
  "list_info": {
    "row_count": 15,
    "search_criteria": [
      {
        "field": "group.name",
        "condition": "is",
        "values": [
          "Network"
        ]
      },
      {
        "field": "status.internal_name",
        "condition": "is",
        "logical_operator": "and",
        "values": [
          "Open"
        ]
      }
    ]
  }
}

2) A&B&(C&D) - A(and)B(and)[C(and)D]

The following list info object will retrieve all the “Open” requests under group “Network” created today

{
  "list_info": {
    "row_count": 15,
    "search_criteria": [
      {
        "field": "group.name",
        "condition": "is",
        "values": [
          "Network"
        ]
      },
      {
        "field": "status.internal_name",
        "condition": "is",
        "logical_operator": "and",
        "values": [
          "Open"
        ]
      },
      {
        "field": "created_time",
        "condition": "greater than",
        "logical_operator": "and",
        "values": [
          "1553731200000"
        ],
        "children": [
          {
            "field": "created_time",
            "condition": "lesser than",
            "logical_operator": "and",
            "values": [
              "1553817599000"
            ]
          }
        ]
      }
    ]
  }
}

3)(AB)&(CD) – [A(or)B]and[C(or)D]

{
  "list_info": {
    "row_count": 15,
    "search_criteria": [
      {
        "field": "status.in_progress",
        "condition": "is",
        "values": [
          true
        ],
        "logical_operator": "AND",
        "children": [
          {
            "field": "status.internal_name",
            "condition": "is",
            "values": [
              "Resolved"
            ],
            "logical_operator": "OR"
          }
        ]
      },
      {
        "field": "priority.name",
        "condition": "is",
        "logical_operator": "AND",
        "values": [
          "High"
        ],
        "children": [
          {
            "field": "urgency.name",
            "condition": "is",
            "values": [
              "Urgent"
            ],
            "logical_operator": "OR"
          }
        ]
      }
    ]
  }
}

Here are some more examples for search criteria

The following will retrieve all the open requests created after a period of time

{
  "list_info": {
    "row_count": 100,
    "search_criteria": {
      "field": "status",
      "condition": "is",
      "value": {
        "id": "100000000000008033",
        "name": "Open"
      },
      "children": [
        {
          "field": "created_time",
          "condition": "greater than",
          "value": "1488451440000",
          "logical_operator": "AND"
        }
      ]
    }
  }
}

The following will retrieve all the open requests matching the below conditions, created_time greater than a period of time subject must starts with a specific value

{
  "list_info": {
    "row_count": 100,
    "search_criteria": {
      "field": "status",
      "condition": "is",
      "values": [
        {
          "id": "100000000000008033",
          "name": "Open"
        }
      ],
      "children": [
        {
          "field": "created_time",
          "condition": "greater than",
          "values": [
            {
              "value": "1488451440000",
              "display_value": "02 Mar 2017, 16:14:00"
            }
          ],
          "logical_operator": "AND"
        },
        {
          "field": "subject",
          "condition": "starts with",
          "values": [
            "quick"
          ],
          "logical_operator": "OR"
        }
      ]
    }
  }
}

The following listinfo object will retrieve the requests matching the conditions

((status is open) and (created time greater than OR subject starts with “quick”)) OR (group is not network and technician is not empty)

{
  "list_info": {
    "row_count": 100,
    "search_criteria": [
      {
        "field": "status",
        "condition": "is",
        "values": [
          {
            "id": "100000000000008033",
            "name": "Open"
          }
        ],
        "logical_operator": "AND",
        "children": [
          {
            "field": "created_time",
            "condition": "greater than",
            "values": [
              {
                "value": "1488451440000",
                "display_value": "02 Mar 2017, 16:14:00"
              }
            ],
            "logical_operator": "AND"
          },
          {
            "field": "subject",
            "condition": "starts with",
            "values": [
              "quick"
            ],
            "logical_operator": "OR"
          }
        ]
      },
      {
        "field": "group",
        "condition": "is not",
        "values": [
          {
            "id": "100000000000008057",
            "name": "Network"
          }
        ],
        "logical_operator": "OR",
        "children": [
          {
            "field": "technician",
            "condition": "is not",
            "logical_operator": "AND"
          }
        ]
      }
    ]
  }
}