This operation builds a set-process-variables command payload. Use it to set one or more variables on a process instance.
The base command is:
processPayloadBuilder.setVariables()
You can use the following options:
| Option | Description |
|---|---|
| withProcessInstance(processInstance: ProcessInstance) | Specifies the process instance on which to set variables. |
| withProcessInstanceId(processInstanceId: string) | Specifies the ID of the process instance on which to set variables. |
| withVariable(name: string, value: any) | Sets a single process variable and its value. |
| withVariables(variables: { [key: string]: any;}) | Sets multiple process variables in a single operation. |
The following is the command example for a single variable:
processPayloadBuilder
.setVariables()
.withProcessInstanceId(variables.processInstanceId)
.withVariable('status', 'Ready')
.build();
processPayloadBuilder.setVariables() creates a set-process-variables payload builder. withProcessInstanceId(variables.processInstanceId) specifies the target process instance using the value stored in the processInstanceId process variable. withVariable('status', 'Ready') sets the status process variable to Ready. build() creates the final command payload.
The following is the command example for multiple variables:
processPayloadBuilder
.setVariables()
.withProcessInstanceId(variables.processInstanceId)
.withVariables({
status: 'Ready',
approved: true,
reviewer: variables.reviewer
})
.build();
processPayloadBuilder.setVariables() creates a set-process-variables payload builder. withProcessInstanceId(variables.processInstanceId) specifies the target process instance. withVariables(...) sets multiple process variables in a single operation. build() creates the final command payload.