cancel
Showing results for 
Search instead for 
Did you mean: 

Custom attributes in workflows

frankb
Champ in-the-making
Champ in-the-making
Hi,

I've created a sample workflow where users can apply for a vacation between dates they can set when the workflow starts.
My question is, how do I store this attribute, and present it in the form in the review task as a infotext?

The workflowModel is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<model name="dw:workflowferiesoknadmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   
   <description>Feriesøknad workflow</description>
   <author>FrankB</author>
   <version>1.0</version>
   
   <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" />
      <import uri="http://www.alfresco.org/model/workflow/1.0" prefix="wf" />
   </imports>
   
   <namespaces>
      <namespace uri="workflow.feriesoknad.model" prefix="dw"/>
   </namespaces>
   
   <types>
      <type name="dw:submitFerieSoknad">
         <parent>bpm:startTask</parent>
         <properties>
            <property name="dw:ferieFra">
               <title>Ferie fra</title>
               <type>d:datetime</type>
               <mandatory>true</mandatory>
            </property>
            <property name="dw:ferieTil">
               <title>Ferie til</title>
               <type>d:datetime</type>
               <mandatory>true</mandatory>
            </property>
         </properties>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>
      <type name="dw:reviewFerieSoknad">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
            </property>
         </overrides>
      </type>
      <type name="dw:completeFerieSoknad">
         <parent>bpm:workflowTask</parent>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>
   </types>
</model>

and the processdefinition is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="dw:feriesoknadWorkflow">
   <swimlane name="initiator" />
   
   <swimlane name="reviewer">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{bpm_assignee}</actor>
      </assignment>
   </swimlane>
   
   <start-state name="start">
      <task name="dw:submitFerieSoknad" swimlane="initiator" />
      <transition name="" to="review" />
   </start-state>
   
   <task-node name="review">
      <task name="dw:reviewFerieSoknad" swimlane="reviewer" />
      <transition name="approve" to="approve" />
      <transition name="reject" to="reject" />
   </task-node>
   
   <node name="approve">
      <event type="node-enter">
         <script>
            <variable name="reviewResult" access="write" />
            <expression>
               reviewResult = "approved";
            </expression>
         </script>
      </event>
      <transition to="completed" />
   </node>
   
   <node name="reject">
      <event type="node-enter">
         <script>
            <variable name="reviewResult" access="write" />
            <expression>
               reviewResult = "rejected";
            </expression>
         </script>
      </event>
      <transition to="completed" />
   </node>
   
   <task-node name="completed">
      <event type="node-enter">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var mail = actions.create("mail");
               mail.parameters.to =
               initiator.properties["cm:email"];
               mail.parameters.subject =
               "Review Task " + bpm_workflowDescription;
               mail.parameters.from
               =bpm_assignee.properties["cm:email"];
               mail.parameters.text=
               "Din feriesøknad har blitt: " + reviewResult + ".";
               mail.execute(bpm_package);
            </script>
         </action>
      </event>
      <task name="dw:completeFerieSoknad" swimlane="initiator" />
      <transition name="" to="end" />
   </task-node>
   
   <end-state name="end" />
</process-definition>

and lastly, the config in share-config-custom.xml
<config evaluator="string-compare" condition="jbpm$dw:feriesoknadWorkflow">
   <forms>
      <form>
        <field-visibility>
         <show id="bpm:workflowDescription" />
         <show id="bpm:assignee" />
         <show id="dw:ferieFra" />
         <show id="dw:ferieTil" />
         <show id="packageItems" />
        </field-visibility>
        <appearance>
         <set id="" appearance="title" label-id="workflow.set.general" />
         <set id="info" appearance="" template="/org/alfresco/components/form/2-column-set.ftl" />
         <set id="assignee" appearance="title" label-id="workflow.set.assignee" />
         <set id="items" appearance="title" label-id="workflow.set.items" />
         <set id="other" appearance="title" label-id="workflow.set.other" />
    
         <field id="bpm:workflowDescription" label-id="workflow.field.message">
           <control template="/org/alfresco/components/form/controls/textarea.ftl">
            <control-param name="style">width: 95%</control-param>
           </control>
         </field>
         <field id="dw:ferieFra" set="info" />
         <field id="dw:ferieTil" set="info" />
         <field id="bpm:assignee" label-id="workflow.field.assign_to" set="assignee" />
         <field id="packageItems" set="items" />
        </appearance>
      </form>
   </forms>
   </config>
  
   <config evaluator="task-type" condition="dw:reviewFerieSoknad">
  <forms>
    <form>
      <field-visibility>
        <show id="message" />
        <show id="taskOwner" />
      <show id="dw:ferieFra" />
      <show id="dw:ferieTil" />
        <show id="bpm:taskId" />
        <show id="bpm:status" />
        <show id="packageItems" />
        <show id="bpm:comment" />
        <show id="transitions" />
      </field-visibility>
      <appearance>
        <set id="" appearance="title" label-id="workflow.set.task.info" />
        <set id="info" appearance="" template="/org/alfresco/components/form/3-column-set.ftl" />
        <set id="progress" appearance="title" label-id="workflow.set.task.progress" />
        <set id="items" appearance="title" label-id="workflow.set.items" />
        <set id="response" appearance="title" label-id="workflow.set.response" />
        <field id="message">
          <control template="/org/alfresco/components/form/controls/info.ftl" />
        </field>
        <field id="taskOwner" set="info" />
      <field id="dw:ferieFra" set="info">
         <control template="/org/alfresco/components/form/controls/info.ftl" />
      </field>
      <field id="dw:ferieTil" set="info">
         <control template="/org/alfresco/components/form/controls/info.ftl" />
      </field>
        <field id="bpm:taskId" set="info">
          <control template="/org/alfresco/components/form/controls/info.ftl" />
        </field>
        <field id="bpm:status" set="progress" />
        <field id="packageItems" set="items" />
        <field id="bpm:comment" label-id="workflow.field.comment" set="response">
          <control template="/org/alfresco/components/form/controls/textarea.ftl" />
        </field>
        <field id="transitions" set="response" />
      </appearance>
    </form>
  </forms>
</config>

What I expect is that these two custom date fields(dw:ferieFra and dw:ferieTil") also will show up in the dw:reviewFerieSoknad task, not just the dw:submitFerieSoknad task.
THe fields show up like I want in the dw:submitFerieSoknad form, but not the dw:reviewFerieSoknad.
What do I have to do to achieve this? Create a custom type, and map the workflow do this type?

Can someone please explain? thanks in advance!

Frank B
1 REPLY 1

predragp
Champ in-the-making
Champ in-the-making
I have same problem with custom fields/attributes, and I see you mark thread as solved.

Can you please  explain me how did you solve this problem?

Tnx in advance
Predrag