cancel
Showing results for 
Search instead for 
Did you mean: 

Display metada from document in a workflow task form

pweigner
Champ in-the-making
Champ in-the-making
I'd like to display metadata assigned to document in workflow task.
I prepared
1. Metadata model for document
2. Metadata model for workflow
3. I designed workflow
4. I configured displaying properties for tasks (webclient/config/costum.xml)
everything was tested and run properly.

I decided to load properties from metadata of a document assigned to workflow.
I created a JavaScript code on transition from task one to task two.

<transition name="send" to="fillData">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                <expression>                                 
                   wfclbMHMPRegimen_wfProjectName = bpm_package.children[0].properties["clbMHMPRegimen:ProjectName"];
                   logger.log("wfclbMHMPRegimen_wfProjectName = " + wfclbMHMPRegimen_wfProjectName);                           
               </expression>
               <variable name="wfclbMHMPRegimen_wfProjectName" access="read,write" />
               
               </script>       
            </action>            
      </transition>

But I got an exception
the variable bpm_package is not defined
.

I have tested also the next case

<transition name="send" to="fillData">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                                              
                   var wfclbMHMPRegimen_wfProjectName = bpm_package.children[0].properties["clbMHMPRegimen:ProjectName"];
                   logger.log("wfclbMHMPRegimen_wfProjectName = " + wfclbMHMPRegimen_wfProjectName);                                    </script>       
            </action>            
      </transition>
There was the package property assigned but not displayed.

I have decided to combine both. bot without success. But I saw the value "Project Name" in task form.

<transition name="send" to="fillData">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                <expression>                                 
                   wfclbMHMPRegimen_wfProjectName = "Project Name";
                   logger.log("wfclbMHMPRegimen_wfProjectName = " + wfclbMHMPRegimen_wfProjectName);                              
               </expression>
               <variable name="wfclbMHMPRegimen_wfProjectName" access="read,write" />
               
               </script>       
            </action>                 
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                                              
                   wfclbMHMPRegimen_wfProjectName = bpm_package.children[0].properties["clbMHMPRegimen:ProjectName"];
                   logger.log("wfclbMHMPRegimen_wfProjectName = " + wfclbMHMPRegimen_wfProjectName);                                       
               
               </script>       
            </action>             
      </transition>

Thanks for your answer…
1 REPLY 1

rob562435
Champ in-the-making
Champ in-the-making
What is missing is the statement
<variable name="bpm_package" access="read" />
as part of the script.
Any variable that is needed inside a script constructed with <expression> must be declared separately.
Be aware of the fact that only one variable may be written in a single script and that the result of the last assignment is given as value to the variable to be written.
In some cases variables can be written without the <expression> but I found that in most cases the usage of <expression> is more falesafe.