3 Replies Latest reply on May 5, 2006 2:54 AM by Ronald van Kuijk

    Unique and dynamic Process instance id

    Raja Mohan Newbie

      We have a business requirement for inserting a unique and a dynamic process instance id when an instance of a workflow is started.

      Is there anyway in the process definition, where i can specify these variables and have them popped up on the web page when that workflow is started?

      I can modify my webapp to read from the processdefinition and display the appropriate jsp page, but is it possible to add new attributes to processdefinition?

      Thanks in advance
      Jbpm beginner

        • 1. Re: Unique and dynamic Process instance id
          Ronald van Kuijk Master

          Adding attributes or custom xml is not realy possible yet. You can achieve some things, but they might change, therefor I do not recommend these.

          What I do myself is when I start a process from a bean (customized version of the jbpm 3.1 webapp (I modified the HomeBean)), I immediately set a process variable with a guid. This works great.

          hth.

          • 2. Re: Unique and dynamic Process instance id
            James Depoorter Novice

            Relatively simple by having handlers creating/adding all sorts of vars like this (package and imports not shown):

            public class VariableActionHandler implements ActionHandler {
            
             private String name;
            
             private String method;
            
             private String value;
            
             public String getName() {
             return name;
             }
            
             public void setName(String name) {
             this.name = name;
             }
            
             public String getValue() {
             return value;
             }
            
             public void setValue(String value) {
             this.value = value;
             }
            
             public String getMethod() {
             return method;
             }
            
             public void setMethod(String method) {
             this.method = method;
             }
            
             public String getValue() {
             return value;
             }
            
             public void setValue(String value) {
             this.value = value;
             }
            
            
             public void execute(ExecutionContext executionContext) throws Exception {
             if ("NAMEVALUE".equals(method)) {
             executionContext.getContextInstance().setVariable(name, value);
             } else {
             // perform other methods like injecting GUIDS, Unique IDS, forward to business logic, etch...
             }
             }
            
            }
            


            Then, in your definition, use an action e.g.
            <node>
             <action class="VariableActionHandler" config-type="bean">
             <name>processId</name>
             <value>123</value>
             <method>NAMEVALUE</method>
             </action>
            </node>
            
            <node>
             <action class="VariableActionHandler" config-type="bean">
             <name>processId</name>
             <method>GENERATEGUID</method>
             </action>
            </node>
            


            • 3. Re: Unique and dynamic Process instance id
              Ronald van Kuijk Master

              Yes, but *not* at the start of a process right? If I have a start task I cannot use this. I even tried task-assign events on the start task, but was not able to set variables that could be used this way at start time.

              For this reason I created a Jira issue to be able to pass variables when creating a process.