How to add a variable manually in cockpit

How to add a variable manually in all instances of the process through the cockpit, how would it be? I know that entering each instance can be added, but as there are many, I didn’t want to enter one by one, or would there be some way directly in the database or rest api?

Hi Marcelo - variables can only be added to a single instance. There is not currently an API to add a variable to all instances in a given process definition. How many instances do you need to update?

This is fairly straightforward to script though using what is available with the REST API

  1. Query to retrieve all instances for the target process definition using GET /process-instance API (not sure how many instances you have to update but would make sure this number isn’t too huge, else it may be best to batch the call)
  2. Loop through the response and store instance ids in an array
  3. Loop through this instance id array and use POST /process-instance/{id}/variables API to update each instance with the variable you want to add

I have 149 instances, I had this idea of ​​looking for the instance ids and running a loop but I thought it was too much work, I thought it had something simpler, but anyway I will develop this script that you recommended. Thank you