AnsweredAssumed Answered

Display custom properties from a Workflow

Question asked by dranakan on Nov 22, 2011
Latest reply on Nov 22, 2011 by dranakan
Hello,

I want to show some custom properties in my workflow from a webscript. I have tried 3 methods :

1. Using Alfresco Wescript : alfresco/service/api/workflow-instances/activiti$3086
(it doesn't show the custom properties).

2. Custom webscript, with JS API
I try getProperties but it still null

var infoWorklow= workflow.getAssignedTasks();
var outputRows="";
        for each (var task in infoWorklow){
                        outputRows +="<br>";
                        outputRows += "<td>"+task.getId() +"</td>";
                        outputRows += "<td>"+task.getName() +"</td>";
                         outputRows += "<td>" + task.getProperties() + "</td>";
                }
3. Custom Webscript, with FTL
Error using the var : Expression t.properties["sgfwf:montant1"] is undefined

<table cellspacing=0 cellpadding=2>
<#list workflow.completedTasks as t>
      <tr>
         <td>${t.id}</td>
         <td>${t.type}</td>
         <td>${t.name}</td>
         <td>${t.description}</td>
         <td>${t.properties["cm:created"]?datetime}</td>
         <td><#if t.properties["bpm:startDate"]?exists>${t.properties["bpm:startDate"]?datetime}<#else><i>None</i></#if></td>
         <td><#if t.properties["bpm:dueDate"]?exists>${t.properties["bpm:dueDate"]?datetime}<#else><i>None</i></#if></td>
         <td>${t.properties["bpm:priority"]}</td>
         <td>${t.properties["bpm:percentComplete"]}</td>
         <td>${t.properties["bpm:status"]}</td>
         <td>${t.isCompleted?string("Yes", "No")}</td>
<td>${t.properties["sgfwf:montant1"]}</td>

      </tr>
   </#list>
</table>

Custom worfklow Model

<?xml version="1.0" encoding="UTF-8"?>
   <!– Definition of a Workflow –>
<model name="sgfwf:workflowModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>
   <description>Custom Workflow Model for Finance</description>
   <author>Custom</author>
   <version>1.0</version>

   <!–
      Imports are required to allow references to definitions in other
      models
   –>
   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0"
         prefix="d" />
      <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm" />
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <namespaces>
      <namespace uri="http://www.custom.ch/model/workflow/finance/1.0"
         prefix="sgfwf" />
   </namespaces>

   <types>
   <type name="sgfwf:submitStart">
         <parent>bpm:startTask</parent>
         <properties>
            <property name="sgfwf:account1">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:centre1">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:genre1">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:montant1">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:libelle1">
               <type>d:text</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:account2">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:centre2">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:genre2">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:montant2">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:libelle2">
               <type>d:text</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:account3">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:centre3">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:genre3">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:montant3">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:libelle3">
               <type>d:text</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:account4">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:centre4">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:genre4">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:montant4">
               <type>d:int</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:libelle4">
               <type>d:text</type>
               <mandatory>false</mandatory>
               <multiple>false</multiple>
            </property>
         <property name="sgfwf:approveRejectOutcome">
                    <type>d:text</type>
                    <default>Reject</default>
                    <constraints>
                        <constraint name="sgfwf:approveRejectOutcomeOptions" type="LIST">
                            <parameter name="allowedValues">
                                <list>
                                    <value>Approve</value>
                                    <value>Reject</value>
                                </list>
                            </parameter>
                        </constraint>
                    </constraints>
                </property>
            </properties>
         <!–  To select a user –>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>
      <type name="sgfwf:modifyReviewTask">
         <parent>sgfwf:submitStart</parent>
      </type>
      <type name="sgfwf:reviewByBoss">
         <parent>sgfwf:submitStart</parent>
      </type>
      <type name="sgfwf:approvedTask">
         <parent>sgfwf:submitStart</parent>
      </type>
      <type name="sgfwf:rejectedTask">
         <parent>sgfwf:submitStart</parent>
      </type>
   </types>
</model>


How can I do ?
Alfresco 4.0b

Thanks :-)

http://wiki.alfresco.com/wiki/Workflow_JavaScript_API
http://wiki.alfresco.com/wiki/FreeMarker_Template_Cookbook#Workflow_Tasks_Example

Outcomes