如何从以前的用户任务中选择Alfresco中的任务受理人?

时间:2016-10-19 08:55:59

标签: forms workflow alfresco activiti

我在Alfresco中创建了一个自定义工作流程及其模型和配置。如果您查看此工作流程示例:

<userTask id="creaCS" name="Crea Certificato di Servizio" activiti:candidateGroups="DSGA" activiti:formKey="psw:activitiCreaCS">
    <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
            <activiti:field name="script">
                <activiti:string><![CDATA[logger.log("Log Log");
                    execution.setVariable('DSGAincaricato', task.getVariable('psw_DSGAincaricato'));
                    execution.setVariable('DSincaricato', task.getVariable('psw_DSincaricato'));]]>
                </activiti:string>
            </activiti:field>
        </activiti:taskListener>
    </extensionElements>
</userTask>
<userTask id="valutaCS" name="Valuta Certificato di Servizio" activiti:assignee="${DSincaricato.properties.userName}" activiti:formKey="psw:activitiValutaCS">
    <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
            <activiti:field name="script">
                <activiti:string>if(task.getVariableLocal('psw_esitoValutazioneCS') == 'Approvato'){
                    execution.setVariable('psw_prosegui', true);
                    }else{
                    execution.setVariable('psw_prosegui', false);
                    }
                </activiti:string>
            </activiti:field>
        </activiti:taskListener>
    </extensionElements>
</userTask>

我想在creaCS中选择valutaCS的受让人。所以我创建了一个像这样的模型:

<type name="psw:activitiCreaCS">
        <parent>bpm:startTask</parent>
        <associations>
            <association name="psw:DSGAincaricato">
                <title>DSGA incaricato</title>
                <source>
                    <mandatory>false</mandatory>
                    <many>false</many>
                </source>
                <target>
                    <class>cm:person</class>
                    <mandatory>false</mandatory>
                    <many>false</many>
                </target>
            </association>
            <association name="psw:DSincaricato">
                <title>DS incaricato</title>
                <source>
                    <mandatory>false</mandatory>
                    <many>false</many>
                </source>
                <target>
                    <class>cm:person</class>
                    <mandatory>false</mandatory>
                    <many>false</many>
                </target>
            </association>
        </associations>
    </type>

    <type name="psw:activitiValutaCS">
        <parent>bpm:activitiOutcomeTask</parent>
        <properties>
            <property name="psw:esitoValutazioneCS">
                <type>d:text</type>
                <default>Respinto</default>
                <constraints>
                    <constraint type="LIST">
                        <parameter name="allowedValues">
                            <list>
                                <value>Approvato</value>
                                <value>Respinto</value>
                            </list>
                        </parameter>
                    </constraint>
                </constraints>
            </property>
        </properties>
        <overrides>
            <property name="bpm:packageItemActionGroup">
                <default>edit_package_item_actions</default>
            </property>
            <property name="bpm:outcomePropertyName">
                <default>{http://www.portaleScuola.com/model/workflow/1.0}esitoValutazioneCS</default>
            </property>
        </overrides>
    </type>

我自定义了表单:

<config evaluator="task-type" condition="psw:activitiCreaCS">
    <forms>
        <form id="workflow-details">
            <field-visibility>
                <show id="bpm:workflowDescription"/>
                <show id="packageItems"/>
                <show id="psw:DSGAincaricato"/>
                <show id="psw:DSincaricato"/>
                <show id="transitions"/>
                <show id="bpm:status"/>
            </field-visibility>
            <appearance>
                <set id="" appearance="title" label-id="workflow.set.general" />
                <set id="items" appearance="title" label-id="workflow.set.items" />
                <set id="progress" appearance="title" label-id="workflow.set.task.progress" />               
                <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="packageItems" set="items" />
                <field set="actors" id="psw:DSGAincaricato">
                    <control template="/org/alfresco/components/form/controls/authority.ftl">

                    </control>
                </field>
                <field set="actors" id="psw:DSincaricato">
                    <control template="/org/alfresco/components/form/controls/authority.ftl">

                    </control>
                </field>
                <field id="bpm:status" set="progress" />
            </appearance>
        </form>
        <form>
            <field-visibility>
                <show id="bpm:workflowDescription"/>
                <show id="packageItems"/>
                <show id="psw:DSGAincaricato"/>
                <show id="psw:DSincaricato"/>
                <show id="transitions"/>
                <show id="bpm:status"/>
            </field-visibility>
            <appearance>
                <set id="" appearance="title" label-id="workflow.set.general" />
                <set id="items" appearance="title" label-id="workflow.set.items" />
                <set id="progress" appearance="title" label-id="workflow.set.task.progress" />               
                <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="packageItems" set="items" />
                <field set="actors" id="psw:DSGAincaricato">
                    <control template="/org/alfresco/components/form/controls/authority.ftl">

                    </control>
                </field>
                <field set="actors" id="psw:DSincaricato">
                    <control template="/org/alfresco/components/form/controls/authority.ftl">

                    </control>
                </field>
                <field id="bpm:status" set="progress" />
            </appearance>
        </form>
    </forms>
</config>

但是有两个问题。首先,我的工作流程没有得到分配,甚至连creaCS中的组分配都没有。 其次,由于某种原因,我的自定义表单中缺少用户的字段。我无法理解为什么,也因为psw_esitoValutazioneCS字段没有任何问题。 有人有任何想法如何解决它?

1 个答案:

答案 0 :(得分:0)

关于任务分配,您可以直接从模型中的属性读取受让人,而不是尝试使用受让人的值设置执行变量然后将其作为受让人读取,如下所示:

<userTask id="valutaCS" name="Valuta Certificato di Servizio" activiti:assignee="${psw_DSincaricato.properties.userName}" activiti:formKey="psw:activitiValutaCS">

关于表单上字段的外观,您是否尝试删除控件?我有一个与你做类似事情的工作流程。它工作得很好,不需要指定特定的控件。

有一件事是我没有看到与使用默认表单创建工作流(condition =“activiti $ processId”)相对应的表单配置。我看到的只是一个表单配置,其类型与提交类型ID相匹配。你需要两者。