cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow Model Problem

mangar
Star Contributor
Star Contributor
I am new to the workflows and i am trying to do a simple private message workflow.  The start task takes a name and a message.  The problem is setting the data.  When I iterate through the task variables I get this very weird problem:

here it the model:


      <type name="jiswf:privateMessage">
         <parent>bpm:startTask</parent>
         <properties>
            <property name="jiswf:toName">
               <type>d:text</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="jiswf:privateMessage">
               <type>d:text</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
            </property>            
         </properties>
      </type>


it is launched by a java web script:


      WorkflowDefinition wfDefinition = workflowService.getDefinitionByName("activiti$privateMessageProcess");
           Map<QName, Serializable> vars = new HashMap<QName, Serializable>();
           vars.put(QName.createQName(AlfrescoModel.WORKFLOW_NAMESPACE,"toName"),toName);
           vars.put(QName.createQName(AlfrescoModel.WORKFLOW_NAMESPACE,"privateMessage"),message);
      workflowService.startWorkflow(wfDefinition.getId(), vars);


and a simple iterator through the variables in the task listener (Java):


      Map<String,Object> vars = task.getVariables();
      Iterator<String> keys = vars.keySet().iterator();
      while(keys.hasNext()) {
         String key = keys.next();
         System.out.println("Key:"+key+" Value:"+vars.get(key));
      }


The output is the issue:


  Key:jiswf_toName Value:joe
  Key:jiswf:privateMessage Value:asdfasdf


Why oh why is one key "jiswf_toName" and the other "jiswfSmiley TonguerivateMessage"

that difference between "_" and ":" makes it hard to get the variables out of the model as you can imagine. Using v4.2.d comm.

Any help is appreciated.
4 REPLIES 4

kaynezhang
World-Class Innovator
World-Class Innovator
Under normal circumstances,when you put qname varaiable into workflow varaiable ,alfresco will convert qname to bpm varaiable (replace : {} to _ ,for example convert jiswf:toName to jiswf_toName).
So technically all varaiables  can be retrieved using underline format.

kaynezhang
World-Class Innovator
World-Class Innovator
Under normal circumstances,when you put qname varaiable into workflow varaiable ,alfresco will convert qname to bpm varaiable (replace : {} to _ ,for example convert jiswf:toName to jiswf_toName).
So technically all varaiables  can be retrieved using underline format.

I understand that. The problem is that it is NOT doing that for the privateMessage variable.  When I do this:

<java>
      String name = (String) task.getVariable("jiswf_toName");
      System.out.println("To Name:"+name);
      
      String message = (String) task.getVariable("jiswfSmiley TonguerivateMessage");
      System.out.println("Message:"+message);
</java>

It works fine, but "jiswf_privateMessage" does not. (I get a null)

Why does toName have an _ and privateMessage has a :  ???

mangar
Star Contributor
Star Contributor
The problem was that I did not place the formKey="jiswfSmiley TonguerivateMessage" in the userTask element in my workflow definition, I placed it in the startEvent

if you look at this thread:  <a>http://forums.alfresco.com/forum/developer-discussions/workflow/get-workflow-task-12072013-2115</a> You will see what I did wrong.

So in my opinion, the above code should not have worked at all. Im not going to fill out a bug report, because if you do it right, it works fine.  It's just weird that it worked at all.