Query for the number of variable instances that fulfill given parameters. This method takes the same message body as theGet Variable Instances (POST) method and therefore it is slightly more powerful than the Get Variable Instance Count method.
Method
POST /variable-instance/count
Parameters
Request Body
A JSON object with the following properties:
Name | Description |
---|---|
variableName | Filter by variable instance name. |
variableNameLike | Filter by the variable instance name. The parameter can include the wildcard % to express like-strategy such as: starts with (% name), ends with (name% ) or contains (% name% ). |
processInstanceIdIn | Only include variable instances which belong to one of the passed process instance ids. |
executionIdIn | Only include variable instances which belong to one of the passed execution ids. |
caseInstanceIdIn | Only include variable instances which belong to one of the passed case instance ids. |
caseExecutionIdIn | Only include variable instances which belong to one of the passed case execution ids. |
taskIdIn | Only include variable instances which belong to one of the passed task ids. |
activityInstanceIdIn | Only include variable instances which belong to one of the passed activity instance ids. |
tenantIdIn | Only include variable instances which belong to one of the passed and comma-separated tenant ids. |
variableValues | A JSON array to only include variable instances that have the certain values. The array consists of objects with the three properties name , operator and value . name (String) is the variable name, operator (String) is the comparison operator to be used and value the variable value. value may be String , Number or Boolean . Valid operator values are: eq - equal to; neq - not equal to; gt - greater than; gteq - greater than or equal to; lt - lower than; lteq - lower than or equal to; like . |
sortBy | Sort the results lexicographically by a given criterion. Valid values are variableName , variableType , activityInstanceId and tenantId . Must be used in conjunction with the sortOrder parameter. |
sortOrder | Sort the results in a given order. Values may be asc for ascending order or desc for descending order. Must be used in conjunction with the sortBy parameter. |
Result
A JSON object that contains the count as the only property.
Name | Value | Description |
---|---|---|
count | Number | The number of matching variable instances. |
Response Codes
Code | Media type | Description |
---|---|---|
200 | application/json | Request successful. |
400 | application/json | Returned if some of the query parameters are invalid, for example if a sortOrder parameter is supplied, but no sortBy , or if an invalid operator for variable comparison is used. See the Introduction for the error response format. |
Example
Request
POST /variable-instance/count
Request Body:
{"variableValuess":
[{"name": "amount",
"operator": "gteq",
"value": "5"
},
{"name": "amount",
"operator": "lteq",
"value": 200}],
"processInstanceIdIn": [ "aProcessInstanceId", "anotherProcessInstanceId" ]}
Response
{"count": 3}
原文: https://docs.camunda.org/manual/7.9/reference/rest/variable-instance/post-query-count/