cancel
Showing results for 
Search instead for 
Did you mean: 

Setting list variables in workflow

akomisarek
Champ in-the-making
Champ in-the-making
Hello,

I know I probably lack basic knowledge to solve my problem, but should be easy for you Smiley Happy. I need to create workflow with two variables, one is locale, another is list of locales (they can be strings doesn't matter), so here is my question how to make convenient way to setting them during creation of workflow?

I created dialog which uses those 2 parameters and user can set them. So here is my question how can I reuse my code? Should I create some kind of new generator and renderer? If yes how can use it in my dialog? Only way I know how to do that is to modify choose-options.jsp page for workflow's wizard but it is obviously something I would like to avoid Smiley Sad.

Thanks for help,
Adam
1 REPLY 1

jarrett
Champ in-the-making
Champ in-the-making
I needed to do something similar to allow a user to pick a peer reviewer and their manager during the start of a workflow. I just wedged my variables into the task that is the start state an advanced workflow. Here are the relevant parts of the config files.

Process Definition

   <start-state name="start">
      <task name="wf:startWorkflow" swimlane="Initiator" />
      <transition to="Peer Review" name="to Peer Review">
         <script>
                 <expression>
                    <!– extract the username from the value selected from the peer dropdown format = "jsmith - John Smith" we need the "jsmith" –>
                    var tempPeer = wf_peer;
                    var pos = tempPeer.indexOf("-");
                    tempPeer = tempPeer.substring(0,(pos-1));
                    
                    PeerReviewer = tempPeer;
                    
               var currentTime = new Date();
               var totTime = (currentTime.getHours() + ":" + currentTime.getMinutes() + ":" + currentTime.getSeconds());
               System.out.println("Capture Peer ID " + totTime + " ######## Ended ######### " + PeerReviewer);                     
            </expression>
            <variable name="wf_peer" access="read" />
            <variable name="PeerReviewer" access="write" />
         </script>
      </transition>
      <event type="task-assign">
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <script>
                   taskInstance.description = "Workflow Started";
               var currentTime = new Date();
               var totTime = (currentTime.getHours() + ":" + currentTime.getMinutes() + ":" + currentTime.getSeconds());
               java.lang.System.out.println("Workflow Started ######### " + totTime + " ##############");                   
                </script>
              </action>         
      </event>   
   </start-state>

Workflow Model

         <type name="wf:startWorkflow">
            <parent>bpm:startTask</parent>
            <properties>
               <property name="wf:peer">
                  <type>d:text</type>
                  <mandatory>true</mandatory>
                  <multiple>false</multiple>
                  <constraints><constraint ref="wf:PeertConstraint" /></constraints>
               </property>            
            </properties>
            <mandatory-aspects>
               <aspect>wf:comments</aspect>
            </mandatory-aspects>
         </type>

web-client-config-custom.xml

   <config evaluator="node-type" condition="wf:startWorkflow" replace="true">
      <property-sheet>
         <separator name="sep1a" display-label-id="general" component-generator="HeaderSeparatorGenerator" />
         <show-property name="wf:peer" />
         <show-property name="wf:newComments" component-generator="FullTextAreaGenerator" />
      </property-sheet>
   </config>

Hope this is the info you needed/ wanted.