You can make location based queries to find indexed process instances and tasks that contain geographical data stored in a named process variable. Both getQueryProcesses and getQueryTasks support filters that will return data within a rectangle or a set distance from a point.
Creating Geographical Data
If the forms used in workflow processes include fields that capture location data, that data can be used in the filters for querying tasks and processes. For location data to be indexed into the search, the "summary form" used by the process (set in the Workflow - Start Action field) must include the field you want to be indexed. By default the summary form is the same form as the one used to start the process.
The standard fields that capture location data are:
These input fields must also be set as "searchable". This is done in the field settings:
Once a searchable location field exists in the form definition, and has been passed to your process as a variable, it can be updated in your process model with new long/lat coordinates. To create searchable location data within your process model (eg via script activities) create placeholder variables in your forms using the hidden location field then set the value in your process.
Query Filters
The following three predicates are supported. They can be used with getQueryProcesses and getQueryTasks.
The
GEOGKEYEXISTS
Checks that a key exists and that it contains geographic data. It then returns/excludes processes depending upon the operator it is used with. Its value should be the name of the variable to test.
Example
This query would return all process instances that have this variable containing location data.
function(params, credentials) {
let result = this.callWorkerMethod("workflow", "getQueryProcesses", {
"useQueryService": true,
"filter": {
"GEOGKEYEXISTS": "form_LOCATIONPICKERFIELD"
}
});
return result;
}
GEOGDISTLT
Filters by processes containing geographic data a given distance from a point.
Property | Type | Description |
---|---|---|
Key | String, required | The name of the variable containing the location data |
GEOGDISTLT | Integer, required | The distance in metres from the supplied point |
to | Object, required | The point to test from |
to.type | String, required | Always Point |
to.coordinates | Array, required | Long/lat coordinates representing a point |
Example
This example combines two operators using AND. It limits the search to tasks of a single process within 4000 metres of a point.
function(params, credentials) {
let result = this.callWorkerMethod("workflow", "getQueryTasks", {
"useQueryService": true,
"filter": {
"AND": [{
"key": "form_LOCATIONPICKERFIELD",
"GEOGDISTLT": 4000,
"to": {
"type": "Point",
"coordinates": [
-0.1847076416015625, 51.465130385364795
]
}
}, {
"key": "processDefinitionKey",
"EQ": "timsgeotest"
}]
}
});
return result;
}
GEOGWITHIN
Filters by processes containing geographic data within a polygon. Note that only rectangles are currently supported.
Property | Type | Description |
---|---|---|
key | String, required | The name of the variable containing the location data |
GEOGWITHIN | Object, required | The area to check within |
GEOGWITHIN.type | String, required | Always Polygon |
GEOGWITHIN.coordinates | Array, required | Long/lat coordinates representing a rectangle |
Example
This example returns all process instances of any type that have location data (stored in the named variable) within a rectangle.
function(params, credentials) {
let result = this.callWorkerMethod("workflow", "getQueryProcesses", {
"useQueryService": true,
"filter": {
"key": "form_LOCATIONPICKERFIELD",
"GEOGWITHIN": {
"type": "Polygon",
"coordinates": [
[
[-0.1847076416015625, 51.465130385364795],
[-0.03398895263671874, 51.465130385364795],
[-0.03398895263671874, 51.519852590742715],
[-0.1847076416015625, 51.519852590742715],
[-0.1847076416015625, 51.465130385364795]
]
]
}
}
});
return result;
}