Query for variable instances that fulfill given parameters through a JSON object. This method is slightly more powerful than theGet Variable Instances method because it allows filtering by multiple variable instances of types String, Number or Boolean.

Method

POST /variable-instance

Parameters

Query Parameters

Name Description
firstResult Pagination of results. Specifies the index of the first result to return.
maxResults Pagination of results. Specifies the maximum number of results to return. Will return less results if there are no more results left.
deserializeValues Determines whether serializable variable values (typically variables that store custom Java objects) should be deserialized on server side (default true).

If set to true, a serializable variable will be deserialized on server side and transformed to JSON using Jackson's POJO/bean property introspection feature. Note that this requires the Java classes of the variable value to be on the REST API's classpath.

If set to false, a serializable variable will be returned in its serialized format. For example, a variable that is serialized as XML will be returned as a JSON string containing XML.

Note: While true is the default value for reasons of backward compatibility, we recommend setting this parameter to false when developing web applications that are independent of the Java process applications deployed to the engine.

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.
sorting

A JSON array of criteria to sort the result by. Each element of the array is a JSON object that specifies one ordering. The position in the array identifies the rank of an ordering, i.e., whether it is primary, secondary, etc. The ordering objects have the following properties:

sortByMandatory. Sort the results lexicographically by a given criterion. Valid values are variableName, variableType, activityInstanceId and tenantId.
sortOrderMandatory. Sort the results in a given order. Values may be asc for ascending order or desc for descending order.

|sortBy|Mandatory. Sort the results lexicographically by a given criterion. Valid values are variableName, variableType, activityInstanceId and tenantId.|sortOrder|Mandatory. Sort the results in a given order. Values may be asc for ascending order or desc for descending order.
|sortBy|Mandatory. Sort the results lexicographically by a given criterion. Valid values are variableName, variableType, activityInstanceId and tenantId.
|sortOrder|Mandatory. Sort the results in a given order. Values may be asc for ascending order or desc for descending order.

Result

A JSON array of variable instance objects. Each variable instance object has the following properties:

Name Value Description
id String The id of the variable instance.
name String The name of the variable instance.
type String The value type of the variable.
Name Value Description
——-
value String/Number/Boolean/Object

NameValueDescription
valueString / Number / Boolean / Object The variable's value. Value differs depending on the variable's type and on the deserializeValues parameter.
typeStringThe value type of the variable.
valueInfoObject A JSON object containing additional, value-type-dependent properties.
For variables of type Object, the following properties are returned:

  • objectTypeName: A string representation of the object's type name.
  • serializationDataFormat: The serialization format used to store the variable.


|value|String / Number / Boolean / Object| The variable's value. Value differs depending on the variable's type and on the deserializeValues parameter.|type|String|The value type of the variable.|valueInfo|Object| A JSON object containing additional, value-type-dependent properties.
For variables of type Object, the following properties are returned:

  • objectTypeName: A string representation of the object's type name.

  • serializationDataFormat: The serialization format used to store the variable.
    |Name|Value|Description
    |——-
    |value|String / Number / Boolean / Object| The variable's value. Value differs depending on the variable's type and on the deserializeValues parameter.
    |type|String|The value type of the variable.
    |valueInfo|Object| A JSON object containing additional, value-type-dependent properties.
    For variables of type Object, the following properties are returned:

  • objectTypeName: A string representation of the object's type name.

  • serializationDataFormat: The serialization format used to store the variable.
    |valueInfo|Object|A JSON object containing additional, value-type-dependent properties.
    For variables of type Object, the following properties are returned:

  • objectTypeName: A string representation of the object's type name.

  • serializationDataFormat: The serialization format used to store the variable.
    |processInstanceId|String|The id of the process instance that this variable instance belongs to.
    |executionId|String|The id of the execution that this variable instance belongs to.
    |caseInstanceId|String|The id of the case instance that this variable instance belongs to.
    |caseExecutionId|String|The id of the case execution that this variable instance belongs to.
    |taskId|String|The id of the task that this variable instance belongs to.
    |activityInstanceId|String|The id of the activity instance that this variable instance belongs to.
    |tenantId|String|The id of the tenant that this variable instance belongs to.
  • 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

    Request Body:

    1. {"variableValuess":
    2. [{"name": "amount",
    3. "operator": "gteq",
    4. "value": "5"
    5. },
    6. {"name": "amount",
    7. "operator": "lteq",
    8. "value": 200}],
    9. "processInstanceIdIn": [ "aProcessInstanceId", "anotherProcessInstanceId" ]},
    10. "sorting":
    11. [{"sortBy": "variableType",
    12. "sortOrder": "asc"
    13. }]
    14. }

    Response

    1. [
    2. {
    3. "id": "someId",
    4. "name": "amount",
    5. "type": "Integer",
    6. "variableType": "integer",
    7. "value": 5,
    8. "processInstanceId": "aProcessInstanceId",
    9. "executionId": "b68b71c9-e310-11e2-beb0-f0def1557726",
    10. "taskId": null,
    11. "activityInstanceId": "Task_1:b68b71ca-e310-11e2-beb0-f0def1557726",
    12. "serializationConfig": null,
    13. "tenantId": null
    14. },
    15. {
    16. "id": "someOtherId",
    17. "name": "amount",
    18. "type": "Integer",
    19. "variableType": "integer",
    20. "value": 15,
    21. "processInstanceId": "aProcessInstanceId",
    22. "executionId": "68b71c9-e310-11e2-beb0-f0def1557726",
    23. "taskId": null,
    24. "activityInstanceId": "Task_1:b68b71ca-e310-11e2-beb0-f0def1557726",
    25. "serializationConfig": null,
    26. "tenantId": null
    27. },
    28. {
    29. "id": "yetAnotherId",
    30. "name": "amount",
    31. "type": "Integer",
    32. "variableType": "integer",
    33. "value": 150,
    34. "processInstanceId": "anotherProcessInstanceId",
    35. "executionId": "68b71c9-e310-11e2-beb0-f0def1557726",
    36. "taskId": null,
    37. "activityInstanceId": "Task_2:b68b71ca-e310-11e2-beb0-f0def1557726",
    38. "serializationConfig": null,
    39. "tenantId": null
    40. }
    41. ]

    原文: https://docs.camunda.org/manual/7.9/reference/rest/variable-instance/post-query/