4 Replies Latest reply on Oct 19, 2011 6:13 AM by mnorsic

    How to remove variable from process

    mnorsic

      Hi All,

       

      is there a way to remove variable from process instance?

      Right now, we have a method

      processInstance.setVariable("variable", value);
      

       

      Beside the obvious solution

      processInstance.setVariable("variable", null);
      

       

      are there any other solutions?

       

      For example, it would be nice to have something like this:

      processInstance.removeVariable("variable");
      

       

      Does it make sense?

       

      Thanks,

      Miljenko

        • 1. Re: How to remove variable from process
          tsurdilovic

          Setting it to null is fine. Your process variable could be used in many other places in the process, for example data input/output associations, expressions etc. Removing it would mean a possibly cascating effect which could cause runtime issues. Could add a convenience method that set it to null as you are doing now but I would not call it "removeVariable".

           

          Hope this helps.

          1 of 1 people found this helpful
          • 2. Re: How to remove variable from process
            mnorsic

            Hi Tihomir,

             

            that makes sense, of course. I don't think we need a separate method for that, it's just that I wanted to know what's the best practice, because I'd like to control variable lifecyle.

            For example, Drools has a different logic for that, where I can insert and retract an object from a knowledge session, so I thought can I use this mechanism in a workflow process scenario, for example to trigger some event when a variable is removed from a process instance.

             

            Thanks,

            Miljenko

            • 3. Re: How to remove variable from process
              tsurdilovic

              You should be able to use rule constraints to accomplish this behaviour.

              1 of 1 people found this helpful
              • 4. Re: How to remove variable from process
                mnorsic

                Hi Tihomir,

                 

                thanks for the tip, I can use rule task to retract variable from knowledge session, as well as for reset process instance variable.

                 

                Miljenko