cancel
Showing results for 
Search instead for 
Did you mean: 

Save Variables without completing Task

dognose
Champ in-the-making
Champ in-the-making
Hello,

I want to save entered Values of an Task, without completing it.
This so far can be achieved by calling runtimeservice.setVariable()

In my XHTML files, im binding the form-fields directly to the processVariableMap, so a call to businessProcess.complete()
will flush that values.

So, without completing the process and having all (updated) values inside the processVariableMap, i need to iterateover the processVariableMap
in order to update the process's internal variableMap using setVariable() as mentioned above.

However the implementation of the ProcessVariableMap neither supports size(), containsKey(), keySet(), values() nor any of the functions I would need
to access all key/value pairs in an iterative way.

So, what to do?

Here's what i want to achieve:


   public String saveChanges(BusinessProcess businessProcess, ProcessVariableMap processVariables){
      //Save all variables.
      for (Map.Entry<String, Object> entry : processVariables.entrySet()) {
         //Save to process using runtimeService
      }
      
      System.out.println("Just saving task.");
      return this.getNavigationOutcome();
   }

but as mentioned:
java.lang.UnsupportedOperationException: org.activiti.cdi.impl.ProcessVariableMap.entrySet() is not supported.

using


this.runtimeservice.setVariables(businessProcess.getExecutionId(), processVariables);

instead of iterating manually results in an Exception also:

Caused by: java.lang.UnsupportedOperationException: org.activiti.cdi.impl.ProcessVariableMap.keySet() is not supported.
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
That's indeed a limitation of the current BusinessProcess and ProcessvariableMap in activiti-cdi. Can you create a Jira-issue for this so we can get this sorted out?