Submits a list of modification instructions to change a process instance's execution state async. A modification instruction is one of the following:

  • Starting execution before an activity
  • Starting execution after an activity on its single outgoing sequence flow
  • Starting execution on a specific sequence flow
  • Cancelling an activity instance, transition instance, or all instances (activity or transition) for an activity
    Instructions are executed asynchronous and in the order they are provided in this request's body. Variables can be provided with every starting instruction.

The exact semantics of modification can be read about in the user guide.

Method

POST /process-instance/{id}/modification-async

Parameters

Path Parameters

Name Description
id The id of the process instance to modify.

Request Body

A JSON object with the following properties:

Name Description
skipCustomListeners Skip execution listener invocation for activities that are started or ended as part of this request.
skipIoMappings Skip execution of input/output variable mappings for activities that are started or ended as part of this request.
instructions A JSON array of modification instructions. The instructions are executed in the order they are in. An instruction may have the following properties:

typeMandatory. One of the following values: cancel, startBeforeActivity, startAfterActivity, startTransition. A cancel instruction requests cancellation of a single activity instance or all instances of one activity. A startBeforeActivity instruction requests to enter a given activity. A startAfterActivity instruction requests to execute the single outgoing sequence flow of a given activity. A startTransition instruction requests to execute a specific sequence flow.
activityIdCan be used with instructions of types startBeforeActivity, startAfterActivity, and cancel. Specifies the activity the instruction targets.
transitionIdCan be used with instructions of types startTransition. Specifies the sequence flow to start.
activityInstanceIdCan be used with instructions of type cancel. Specifies the activity instance to cancel. Valid values are the activity instance IDs supplied by the Get Activity Instance request.
transitionInstanceIdCan be used with instructions of type cancel. Specifies the transition instance to cancel. Valid values are the transition instance IDs supplied by the Get Activity Instance request.
ancestorActivityInstanceId
Can be used with instructions of type startBeforeActivity, startAfterActivity, and startTransition. Valid values are the activity instance IDs supplied by the Get Activity Instance request.

If there are multiple parent activity instances of the targeted activity, this specifies the ancestor scope in which hierarchy the activity/transition is to be instantiated.

Example: When there are two instances of a subprocess and an activity contained in the subprocess is to be started, this parameter allows to specify under which subprocess instance the activity should be started.


|type|Mandatory. One of the following values: cancel, startBeforeActivity, startAfterActivity, startTransition. A cancel instruction requests cancellation of a single activity instance or all instances of one activity. A startBeforeActivity instruction requests to enter a given activity. A startAfterActivity instruction requests to execute the single outgoing sequence flow of a given activity. A startTransition instruction requests to execute a specific sequence flow.|activityId|Can be used with instructions of types startBeforeActivity, startAfterActivity, and cancel. Specifies the activity the instruction targets.|transitionId|Can be used with instructions of types startTransition. Specifies the sequence flow to start.|activityInstanceId|Can be used with instructions of type cancel. Specifies the activity instance to cancel. Valid values are the activity instance IDs supplied by the Get Activity Instance request.|transitionInstanceId|Can be used with instructions of type cancel. Specifies the transition instance to cancel. Valid values are the transition instance IDs supplied by the Get Activity Instance request.|ancestorActivityInstanceId|
Can be used with instructions of type startBeforeActivity, startAfterActivity, and startTransition. Valid values are the activity instance IDs supplied by the Get Activity Instance request.

If there are multiple parent activity instances of the targeted activity, this specifies the ancestor scope in which hierarchy the activity/transition is to be instantiated.

Example: When there are two instances of a subprocess and an activity contained in the subprocess is to be started, this parameter allows to specify under which subprocess instance the activity should be started.

|type|Mandatory. One of the following values: cancel, startBeforeActivity, startAfterActivity, startTransition. A cancel instruction requests cancellation of a single activity instance or all instances of one activity. A startBeforeActivity instruction requests to enter a given activity. A startAfterActivity instruction requests to execute the single outgoing sequence flow of a given activity. A startTransition instruction requests to execute a specific sequence flow.
|activityId|Can be used with instructions of types startBeforeActivity, startAfterActivity, and cancel. Specifies the activity the instruction targets.
|transitionId|Can be used with instructions of types startTransition. Specifies the sequence flow to start.
|activityInstanceId|Can be used with instructions of type cancel. Specifies the activity instance to cancel. Valid values are the activity instance IDs supplied by the Get Activity Instance request.
|transitionInstanceId|Can be used with instructions of type cancel. Specifies the transition instance to cancel. Valid values are the transition instance IDs supplied by the Get Activity Instance request.
|ancestorActivityInstanceId|
Can be used with instructions of type startBeforeActivity, startAfterActivity, and startTransition. Valid values are the activity instance IDs supplied by the Get Activity Instance request.

If there are multiple parent activity instances of the targeted activity, this specifies the ancestor scope in which hierarchy the activity/transition is to be instantiated.

Example: When there are two instances of a subprocess and an activity contained in the subprocess is to be started, this parameter allows to specify under which subprocess instance the activity should be started.

Result

A JSON object corresponding to the Batch interface in the engine. Itsproperties are as follows:

Name Value Description
id String The id of the created batch.
type String The type of the created batch.
totalJobs Number The total jobs of a batch is the number of batch execution jobs required to complete the batch.
batchJobsPerSeed Number The number of batch execution jobs created per seed job invocation. The batch seed job is invoked until it has created all batch execution jobs required by the batch (see totalJobs property).
invocationsPerBatchJob Number Every batch execution job invokes the command executed by the batch invocationsPerBatchJob times. E.g., for a process instance modification batch this specifies the number of process instances which are modified per batch execution job.
seedJobDefinitionId String The job definition id for the seed jobs of this batch.
monitorJobDefinitionId String The job definition id for the monitor jobs of this batch.
batchJobDefinitionId String The job definition id for the batch execution jobs of this batch.
tenantId String The tenant id of the batch.

Response Codes

Code Media type Description
200 application/json Request successful.
400 application/json At least one modification instruction misses required parameters.
403 application/json If the user is not allowed to execute batches. See the Introduction for the error response format.
500 application/json The modification cannot be performed, for example because it starts a failing activity.

Example

Request

POST /process-instance/aProcessInstanceId/modification-async

Request Body:

  1. {
  2. "skipCustomListeners": true,
  3. "skipIoMappings": true,
  4. "instructions": [
  5. {
  6. "type": "startBeforeActivity",
  7. "activityId": "activityId"
  8. },
  9. {
  10. "type": "cancel",
  11. "activityInstanceId": "anActivityInstanceId",
  12. }
  13. ]
  14. }

Response

Status 200.

  1. {
  2. "id": "aBatchId",
  3. "type": "instance-modification",
  4. "totalJobs": 10,
  5. "batchJobsPerSeed": 100,
  6. "invocationsPerBatchJob": 1,
  7. "seedJobDefinitionId": "aSeedJobDefinitionId",
  8. "monitorJobDefinitionId": "aMonitorJobDefinitionId",
  9. "batchJobDefinitionId": "aBatchJobDefinitionId",
  10. "tenantId": "aTenantId"
  11. }

原文: https://docs.camunda.org/manual/7.9/reference/rest/process-instance/post-modification-async/