2 Replies Latest reply on Oct 5, 2010 2:05 PM by Yongtao You

    ExecutionService.setVariable() Question

    Yongtao You Newbie



      We are using jBPM 4.3. We start the process execution by


      ExecutionService.startProcessInstanceByKey(key, variables);


      Half way through the workflow we want to modify one of the variables, say X, so that the remaining steps will pickup the new value. We tried:


      ExecutionService.setVariable(executionId, "X", "new value");


      That didn't work. In the remaining steps of the workflow we still see the old value of X.


      What did we do wrong? Any advice?




        • 1. Re: ExecutionService.setVariable() Question
          HuiSheng Xu Master

          Hi Yongtao,


            Did you re-get the process instance by using executionService.findProcessInstanceById()?  The process instance won't synchronize data from database automaticly,  Once we modify the process instance, as variable or signaling,  we need re-get process instance.


            Hope this may be help.



          • 2. Re: ExecutionService.setVariable() Question
            Yongtao You Newbie

            Thanks HuiSheng,


            Yes I did re-get the process instance. It did not help.


            However, I found a workaround. Instead of calling


            ExecutionService.setVariable(executionId, "X", "new value");


            I pass a map of variables (and their new values) to the TaskService.completeTask() call. This works just fine for me since I only need those new values in the subsequent steps.