cancel
Showing results for 
Search instead for 
Did you mean: 

Custom metadata in workflow

agz
Champ on-the-rise
Champ on-the-rise
Hi all,
I need to have a custom association (a user) when the workflow start.

I try to explain:
the workflow has two step approvation:
1. parallel approvation (1..N persons)
2. one person approvation

The first step is the normal "parallel review workflow", for the second step I've attached to this wf another simple approvation step (with a single user).
Now I need to allow user to choice the person of second step approvation.
I think this may be an association (of type cmSmiley Tongueerson).
I want that this association will appear in workflow UI allowing user choice.

I've tried the approach explained here: http://techblog.zabuchy.net/2012/creation-of-workflow-in-alfresco-using-activiti-step-by-step/ and I read the Jeff Potts article about custom wf…but with no results!  :cry:  :cry:  :cry:

How is it possible to have this behaviour?

Thanks in advance
7 REPLIES 7

mitpatoliya
Star Collaborator
Star Collaborator
this is JBPM or Activii workflow?
You are using Alfresco Explorer or Share?
Also post the piece of code where you are trying to add the user.

agz
Champ on-the-rise
Champ on-the-rise
Sorry,
I will more precise:
is an Activiti workflow and I'm using Share in Alfresco community 4.0.e.

In Share, when workflow start, I need to have the possibility to choice a user. This user will be assigned to a task (so we need to have the username).

I think that this behaviour is possible by defining an association..something like:

<association name="drp:Approvator">
  <title>Approvator</title>
  <source>
    <mandatory>false</mandatory>
    <many>true</many>
  </source>
  <target>
    <class>cm:person</class>
    <mandatory>false</mandatory>
    <many>true</many>
  </target>
</association>
Is this a correct solution? If yes, for the moment I'm not able to have this bahaviour (surely something is wrong!).

If someone think this is wrong and know a better solution…I'm here!!  Smiley Happy

Thanks

romschn
Star Collaborator
Star Collaborator
Hi,

Make sure you have implemented in a following way to be able to show the user selection option on the workflow start task.

1. Define the custom assignee in your workflow model.

<aspects>
<aspect name="custom:approver">
            <associations>
                <association name="custom:approver">
                    <source>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </source>
                    <target>
                        <class>cm:person</class>
                        <mandatory>true</mandatory>
                        <many>false</many>
                    </target>
                </association>
               </associations>
        </aspect>
</aspects>

2. In your workflow model, you must define the start task entry and add the assignee aspect to it. Similary as below example.
   

     <type name="custom:startWorkflowTask">
         <parent>bpm:startTask</parent>
       <mandatory-aspects>
            <aspect>custom:approver</aspect>
         </mandatory-aspects>
       </type>
   

3. Make sure you have correctly defined the formkey for your start event in your process definition file.
   

        <process id="customWorkflowName" name="My Custom Workflow">
         <startEvent id="start" activiti:formKey="custom:startWorkflowTask" />
   

4. Make the start task entry for your workflow in the share-config-cusom.xml file as below. I have shown only one field-assignee in below example, you can show other fields as well.

<config evaluator="string-compare" condition="activiti$customWorkflowName">
<forms>
         <form>
            <field-visibility>
                      <show id="custom:approver" />
            </field-visibility>
            <appearance>
                       <set id="assignee" appearance="title" label-id="workflow.set.assignee" />
                        <field id="custom:approver" label-id="workflow.field.reviewer" set="assignee" />
            </appearance>
</config>


Hope this helps.

Thanks,
——————————————————–
Do give a point if it was helpful to you.

agz
Champ on-the-rise
Champ on-the-rise
Thanks for the help.

I try this approach, in detail:

1. —————-
I definded my workflow custom model:

<?xml version="1.0" encoding="UTF-8"?>
<model name="wf:workflowmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
      <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
      <import uri="http://www.alfresco.org/model/user/1.0" prefix="usr" />
      <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm" />
   </imports>
   <namespaces>
      <namespace uri="http://www.alfresco.org/model/workflow/1.0" prefix="wf" />
      <namespace uri="http://www.alfresco.org/drp/model/1.0" prefix="drp" />
   </namespaces>

   <types>
   <type name="drp:startWorkflowTask">
         <parent>bpm:startTask</parent>
       <mandatory-aspects>
            <aspect>drp:aspApprovation</aspect>
         </mandatory-aspects>
       </type>
   </types>

   <aspects>
      <aspect name="drp:aspApprovation">
            <associations>
                <association name="drp:approver">
                    <source>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </source>
                    <target>
                        <class>cm:person</class>
                        <mandatory>true</mandatory>
                        <many>false</many>
                    </target>
                </association>
               </associations>
        </aspect>
   </aspects>
</model>
with type drp:startWorkflowTask and aspect drp:aspApprovation containing drp:approver association of cmSmiley Tongueerson.
I named this file "workflowModel-custom.xml" and saved in alfresco-4.0.e/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/workflow/

2. I modified start task of workflow definition (file approvation.bpmn20.xml):

<startEvent id="start" name="Start" activiti:formKey="drp:startWorkflowTask"></startEvent>

3. I modified share-config-custom.xml adding:

<config evaluator="string-compare" condition="activiti$Approvation">
      <forms>
         <form>
            <field-visibility>
               <show id="bpm:workflowDescription" />
               <show id="bpm:workflowDueDate" />
               <show id="bpm:workflowPriority" />
               <show id="bpm:assignees" />
               <show id="drp:approver" force="true"/>
               <show id="wf:requiredApprovePercent" />
               <show id="packageItems" />
               <show id="bpm:sendEMailNotifications" />
            </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.assignees" />
               <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="bpm:workflowDueDate" label-id="workflow.field.due" set="info" />
               <field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info">
                  <control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
               </field>
               <field id="wf:requiredApprovePercent" set="assignee" />
               <field id="bpm:assignees" label="Revisors" set="assignee" />
               <field id="drp:approver" label="Approvator" set="assignee" />
               <field id="packageItems" set="items" />
               <field id="bpm:sendEMailNotifications" set="other">
                  <control template="/org/alfresco/components/form/controls/workflow/email-notification.ftl" />
               </field>
            </appearance>
         </form>
      </forms>
   </config>

4. RE-deploy of workflow and restart tomcat

The form doesn't show the association.

Where I went wrong?  :evil:

romschn
Star Collaborator
Star Collaborator
Try doing below and see if it works for you or not.

1. Please change the name of your workflow model.
<model name="wf:workflowmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<model name="drp:customworkflowmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

2. Remove this entry. <namespace uri="http://www.alfresco.org/model/workflow/1.0" prefix="wf" />

3. I am assuming that in your process definition file, process id is "Approvation".

Hope this helps.

Thanks,

Do give a point if it was helpful to you.

agz
Champ on-the-rise
Champ on-the-rise
1. Now the name of wf model is:
<model name="drp:customworkflowmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">


2. I removed the wf namespace entry

3. Sure, the process id is Approvation
<process id="Approvation" name="DRP Approvation">


bou it doesn't work!  Smiley Indifferent

agz
Champ on-the-rise
Champ on-the-rise
When I choice to start wf from wf menù in Share, I have in the log this warning:
Type not found: {http://www.alfresco.org/drp/model/1.0}startWorkflowTask

Peraphs the model need to be deployed in other manner?