I have modified current lifecycle workflow according to the form fields I need but that workflow is only good for one step of approval. So if i start the workflow and assign it to somebody, he/she would just approve/reject it and that comes back to me.
What I need is if first approver approves the workflow, it should go to the second approver and if approved/rejected should go back to the Initiator (me in this case)
My acitiviti definition file is
<?xml version="1.0" encoding="UTF-8" ?>
<definitions id="reimbur-definitions"
typeLanguage="http://www.w3.org/2001/XMLSchema"
expressionLanguage="http://www.w3.org/1999/XPath"
targetNamespace="http://activiti.org/bpmn20"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:activiti="http://activiti.org/bpmn">
<process id="activitireimburApproval" name="Reimbursement Application Process">
<extensionElements>
<!-- When process is deleted/cancelled, status should be set to draft -->
<activiti:executionListener event="end" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string>
if(cancelled || deleted) {
for (var i = 0; i < bpm_package.children.length; i++)
{
if (!bpm_package.children[i].hasAspect("rei:status"))
{
bpm_package.children[i].properties["rei:status"] = "Draft";
bpm_package.children[i].save();
}
}
}
</activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
<startEvent id="start"
activiti:formKey="rei:reimbursubmitReviewTask" name="Submit Application" />
<sequenceFlow id='flow1'
sourceRef='start'
targetRef='reviewTask'>
<extensionElements>
<activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string>
for (var i = 0; i < bpm_package.children.length; i++)
{
if (!bpm_package.children[i].hasAspect("rei:status"))
{
bpm_package.children[i].addAspect("rei:status");
}
}
</activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
</sequenceFlow>
<userTask id="reviewTask" name="Review Reimbursement Application"
activiti:formKey="rei:reimburactivitiReviewTask">
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
for (var i = 0; i < bpm_package.children.length; i++)
{
if (bpm_package.children[0].hasAspect("rei:status")) {
bpm_package.children[i].properties["rei:status"] = "In Review";
bpm_package.children[i].save();
}
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="assignment" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
<humanPerformer>
<resourceAssignmentExpression>
<formalExpression>${bpm_assignee.properties.userName}</formalExpression>
</resourceAssignmentExpression>
</humanPerformer>
</userTask>
<sequenceFlow id='flow2'
sourceRef='reviewTask'
targetRef='reviewDecision' />
<userTask id="reviewTask2" name="Review Reimbursement Application"
activiti:formKey="rei:reimburactivitiReviewTask">
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
for (var i = 0; i < bpm_package.children.length; i++)
{
if (bpm_package.children[0].hasAspect("rei:status")) {
bpm_package.children[i].properties["rei:status"] = "In Review";
bpm_package.children[i].save();
}
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
<humanPerformer>
<resourceAssignmentExpression>
<formalExpression>${bpm_assignee.properties.userName}</formalExpression>
</resourceAssignmentExpression>
</humanPerformer>
</userTask>
<sequenceFlow id='flow3'
sourceRef='reviewTask2'
targetRef='reviewDecision' />
<exclusiveGateway id="reviewDecision" name="Review Reimbursement Application" />
<sequenceFlow id='flow4' sourceRef='reviewDecision' targetRef='approved' >
<conditionExpression xsi:type="tFormalExpression">${wf_reviewOutcome == 'Approve'}</conditionExpression>
</sequenceFlow>
<sequenceFlow id='flow5'
sourceRef='reviewDecision'
targetRef='rejected' />
<userTask id="approved" name="Reimbursement Approved"
activiti:formKey="wf:approvedTask" >
<documentation>
The document was reviewed and approved.
</documentation>
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
for (var i = 0; i < bpm_package.children.length; i++)
{
if (bpm_package.children[0].hasAspect("rei:status")) {
bpm_package.children[i].properties["rei:status"] = "Approved";
bpm_package.children[i].save();
}
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
<humanPerformer>
<resourceAssignmentExpression>
<formalExpression>${initiator.properties.userName}</formalExpression>
</resourceAssignmentExpression>
</humanPerformer>
</userTask>
<userTask id="rejected" name="Reimbursement Rejected"
activiti:formKey="wf:rejectedTask" >
<documentation>
The reimbursement was reviewed and rejected.
</documentation>
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
for (var i = 0; i < bpm_package.children.length; i++)
{
if (bpm_package.children[0].hasAspect("rei:status"))
{
bpm_package.children[i].properties["rei:status"] = "Draft";
bpm_package.children[i].save();
}
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
<humanPerformer>
<resourceAssignmentExpression>
<formalExpression>${initiator.properties.userName}</formalExpression>
</resourceAssignmentExpression>
</humanPerformer>
</userTask>
<sequenceFlow id='flow6' sourceRef='approved'
targetRef='end' />
<sequenceFlow id='flow7' sourceRef='rejected'
targetRef='end' />
<endEvent id="end" />
</process>
</definitions>
My model file is
<?xml version="1.0" encoding="UTF-8"?>
<model name="rei:workflowreimburmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!-- Optional meta-data about the model -->
<description>Workflow reimbur Model</description>
<author></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/content/1.0" prefix="cm" />
<import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm" />
<import uri="http://www.alfresco.org/model/user/1.0" prefix="usr" />
<import uri="http://www.alfresco.org/model/workflow/1.0" prefix="wf" />
</imports>
<namespaces>
<namespace uri="rei.model" prefix="rei" />
</namespaces>
<constraints>
<constraint name="rei:status" type="LIST">
<parameter name="allowedValues">
<list>
<value>Draft</value>
<value>In Review</value>
<value>Approved</value>
</list>
</parameter>
</constraint>
</constraints>
<types>
<type name="rei:reimbursubmitReviewTask">
<title>Submit Reimbursement Application</title>
<parent>wf:submitReviewTask</parent>
<mandatory-aspects>
<aspect>rei:myAspect</aspect>
</mandatory-aspects>
</type>
<type name="rei:reimburactivitiReviewTask">
<parent>wf:activitiReviewTask</parent>
<mandatory-aspects>
<aspect>rei:myAspect</aspect>
</mandatory-aspects>
</type>
</types>
<aspects>
<!-- Status property is used to manage workflow approval -->
<aspect name="rei:status">
<title>Status</title>
<properties>
<property name="rei:status">
<title>Status</title>
<type>d:text</type>
<default>Draft</default>
<constraints>
<constraint ref="rei:status" />
</constraints>
</property>
</properties>
</aspect>
<aspect name="rei:myAspect">
<title>My Aspect</title>
<properties>
<property name="rei:workflowAmount">
<type>d:float</type>
<mandatory>true</mandatory>
</property>
</properties>
</aspect>
</aspects>
</model>
and my share-congif-form file is
<config evaluator="string-compare" condition="activiti$activitireimburApproval">
<forms>
<form>
<field-visibility>
<show id="bpm:workflowDescription" />
<show id="rei:workflowAmount" />
<show id="bpm:assignee" />
<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/3-column-set.ftl" />
<set id="assignee" appearance="title" label-id="workflow.set.assignee" />
<set id="other" appearance="title" label-id="workflow.set.other" />
<field id="bpm:workflowDescription" label-id="Expenditure was for" mandatory="true">
<control template="/org/alfresco/components/form/controls/textarea.ftl">
<control-param name="style">width: 95%</control-param>
</control>
</field>
<field id="rei:workflowAmount" label-id="Amount ($)" set="info" mandatory="true">
<control template="/org/alfresco/components/form/controls/textfield.ftl">
</control>
</field>
<field id="bpm:assignee" label-id="workflow.field.reviewer" set="assignee" />
<field id="bpm:sendEMailNotifications" set="other" read-only="true">
<control template="/org/alfresco/components/form/controls/workflow/email-notification.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
<config evaluator="task-type" condition="rei:reimbursubmitReviewTask">
<forms>
<form id="workflow-details">
<field-visibility>
<show id="bpm:sendEMailNotifications" />
</field-visibility>
<appearance>
<set id="" appearance="title" label-id="workflow.set.workflow.more_info" />
</appearance>
</form>
<form>
<field-visibility>
<show id="message" />
<show id="taskOwner" />
<show id="bpm:taskId" />
<show id="bpm:status" />
<show id="rei:workflowAmount" />
<show id="bpm:assignee" />
<show id="bpm:sendEMailNotifications" />
</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="other" appearance="title" label-id="workflow.set.other" />
<field id="message">
<control template="/org/alfresco/components/form/controls/info.ftl" />
</field>
<field id="taskOwner" set="info" />
<field id="bpm:taskId" set="info">
<control template="/org/alfresco/components/form/controls/info.ftl" />
</field>
<field id="rei:workflowAmount" set="info" label-id="Amount ($)">
<control template="/org/alfresco/components/form/controls/info.ftl" />
</field>
<field id="bpm:assignee" label-id="workflow.field.assign_to" set="assignee" />
<field id="bpm:status" set="progress" />
<field id="bpm:sendEMailNotifications" set="other" />
</appearance>
</form>
</forms>
</config>
<config evaluator="task-type" condition="rei:reimburactivitiReviewTask">
<forms>
<form>
<field-visibility>
<show id="message" />
<show id="taskOwner" />
<show id="bpm:assignee" />
<show id="rei:workflowAmount" />
<show id="bpm:taskId" />
<show id="bpm:status" />
<show id="bpm:comment" />
<show id="wf:reviewOutcome" />
</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="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="bpm:taskId" set="info">
<control template="/org/alfresco/components/form/controls/info.ftl" />
</field>
<field id="rei:workflowAmount" set="info" label-id="Amount ($)">
<control template="/org/alfresco/components/form/controls/info.ftl" />
</field>
<field id="bpm:status" set="progress" />
<field id="bpm:assignee" label-id="workflow.field.assign_to" set="assignee" />
<field id="bpm:comment" label-id="workflow.field.comment" set="response">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="wf:reviewOutcome" label-id="workflow.field.outcome" set="response">
<control template="/org/alfresco/components/form/controls/workflow/activiti-transitions.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
In above files, I wanted to have the assignee field appearing in the first approver form, so that he/she can assign it to second approver. But I do not see that on the task/workflow description window and after the approval/rejection, the workflow does not go to the second approver instead comes back to the initiator.
What am I doing wrong? Please guide me.
Thanks in advance.
well, i don't use share, but if i understand well you should make first approval "userTask id="reviewtask" point to the "reviewtask2"
so here:
<sequenceFlow id='flow4' sourceRef='reviewDecision' targetRef='approved' >
<conditionExpression xsi:type="tFormalExpression">${wf_reviewOutcome == 'Approve'}</conditionExpression>
</sequenceFlow>
should be:
<sequenceFlow id='flow4' sourceRef='reviewDecision' targetRef='reviewTask2' >
<conditionExpression xsi:type="tFormalExpression">${wf_reviewOutcome == 'Approve'}</conditionExpression>
</sequenceFlow>
And at the end of reviewTask2:
<humanPerformer>
<resourceAssignmentExpression>
<formalExpression>${initiator.properties.userName}</formalExpression>
</resourceAssignmentExpression>
</humanPerformer>
Maybe you'll need some adjustments here and there, but the logic should be ok..
Let me know if it's ok.
Related
I would like to know how the document list is rendered on workflow details page in Alfresco Share. I mean which components (Java class, Java script, FTL, XML) are responsible to add document list on in workflow-details page.
I searched through the code and found workflow-form.get.html.ftl, however it takes care of all other data to be rendered on this page except document list. Its getting populated dynamically it seems but I don't understand how.
Thanks,
Hemant
If you look at the source on that page you'll find a clue:
<label for="page_x002e_data-form_x002e_task-edit_x0023_default_assoc_packageItems-cntrl">Items:</label>
If you go grep for "packageItems" you'll soon find that a form control called packageitems.ftl:
target/share-war/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/form/controls/workflow/packageitems.ftl
If you go look at that form control it should give you a good starting point in understanding how it works.
It was always confusing for me as well.For defining the workflow details field, there is a separate form for it.
For each workflow there is start task which we are defining in workflow model.for this start task we need to define workflow details form as well.
Below is one of the example where for bpm:startTask workflow-details form is defined.
<config evaluator="task-type" condition="bpm:startTask">
<forms>
**<form id="workflow-details">
<field-visibility>
<show id="bpm:sendEMailNotifications" />
<show id="packageItems" />
</field-visibility>
<appearance>
<set id="" appearance="title" label-id="workflow.set.workflow.more_info" />
<set id="items" appearance="title" label-id="workflow.set.items" />
<field id="packageItems" set="items" />
</appearance>
</form>**
<form>
<field-visibility>
<show id="message" />
<show id="taskOwner" />
<show id="bpm:workflowPriority" />
<show id="bpm:workflowDueDate" />
<show id="bpm:taskId" />
<show id="bpm:status" />
<show id="packageItems" />
<show id="bpm:sendEMailNotifications" />
</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="other" appearance="title" label-id="workflow.set.other" />
<field id="message">
<control template="/org/alfresco/components/form/controls/info.ftl" />
</field>
<field id="taskOwner" set="info" />
<field id="bpm:taskId" set="info">
<control template="/org/alfresco/components/form/controls/info.ftl" />
</field>
<field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info" read-only="true">
<control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
</field>
<field id="bpm:workflowDueDate" set="info" label-id="workflow.field.due">
<control template="/org/alfresco/components/form/controls/info.ftl" />
</field>
<field id="bpm:status" set="progress" />
<field id="bpm:sendEMailNotifications" set="other" />
<field id="packageItems" set="items" />
</appearance>
</form>
</forms>
If you would like to change anything in document list rendering you can extend packageitems.ftl which is suggested by Jeff.
I need to hide workflow task custom properties from the workflow-details and task-details page and show only on task-edit page.Currently it is visible on all the three pages.
abcmodel.xml
<type name="abc:review">
<parent>bpm:activitiOutcomeTask</parent>
<mandatory-aspects>
<aspect>abc:Info</aspect>
</mandatory-aspects>
</type>
<aspects>
<aspect name="abc:Info">
<properties>
<property name="abc:Det">
<type>d:mltext</type>
</property>
</properties>
</aspect>
</aspects>
shareconfigcustom.xml
<config evaluator="task-type" condition="abc:review">
<forms>
<form>
<field-visibility>
<show id="abc:Det"/>
<show id="bpm:comment" />
</field-visibility>
<appearance>
<field id="abc:Det" label="customproperty" read-only="true">
<control template="/org/alfresco/components/form/controls/textarea.ftl">
<control-param name="style">color: black</control-param>
<control-param name="rows">6</control-param>
<control-param name="columns">6</control-param>
</control>
</field>
<field id="bpm:comment" label="Comments">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
You can use form-id to control them.
To hide the field(abc:det) in the workflow details page, you can use like,
<config evaluator="task-type" condition="abc:review">
<forms>
<form>
<field-visibility>
<show id="abc:Det"/>
<show id="bpm:comment" />
</field-visibility>
<appearance>
<field id="abc:Det" label="customproperty" read-only="true">
<control template="/org/alfresco/components/form/controls/textarea.ftl">
<control-param name="style">color: black</control-param>
<control-param name="rows">6</control-param>
<control-param name="columns">6</control-param>
</control>
</field>
<field id="bpm:comment" label="Comments">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
</appearance>
</form>
<!-- Form configuration for workflow-details page -->
<form id="workflow-details">
<field-visibility>
<hide id="abc:Det"/>
<show id="bpm:comment" />
</field-visibility>
<appearance>
.....
</appearance>
</form>
<!-- Form configuration for task-details page -->
<form id="task-details">
<field-visibility>
<hide id="abc:Det"/>
<show id="bpm:comment" />
</field-visibility>
<appearance>
.....
</appearance>
</form>
</forms>
</config>
I hope you can use, '' to configure the task-details, but I haven't tried it yet.
Update
For the task-details, there is no specific form-id is used in data-form section. Refer C:\<Alfresco_Home>\tomcat\webapps\share\WEB-INF\classes\alfresco\site-data\pages\task-details.xml
<!-- Data Form -->
<component>
<region-id>data-form</region-id>
<url>/components/form</url>
<properties>
<itemKind>task</itemKind>
<itemId>{taskId}</itemId>
<mode>view</mode>
<formUI>true</formUI>
</properties>
</component>
To customise this task-details form, I added <formId>task-details</formId> as mentioned below.
<!-- Data Form -->
<component>
<region-id>data-form</region-id>
<url>/components/form</url>
<properties>
<itemKind>task</itemKind>
<itemId>{taskId}</itemId>
<mode>view</mode>
<formUI>true</formUI>
<formId>task-details</formId>
</properties>
</component>
You need to use share extension / customisation best practices to change the OOTB files in share.
Alfresco Share extensions
Finally in the share-config-custom.xml file add the configuration like,
<form id="task-details">
<field-visibility>
<hide id="abc:Det"/>
<show id="bpm:comment" />
</field-visibility>
<appearance>
.....
</appearance>
</form>
All set to go and it is working fine to me.
I am trying to add a text field to the standard adhoc workflow but the field never appears on the screen. I have tried added some other standard bpm: fields to the view and they get displayed but not the custom one.
Is there anything obvious I am missing?
I have cloned the workflow and added the following.
Workflow model:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Definition of new Model -->
<model name="lhwf:workflowmodel"
xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!-- Optional meta-data about the model -->
<description>Workflow Model</description>
<author>O</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" />
<import uri="http://www.alfresco.org/model/workflow/1.0"
prefix="wf"/>
</imports>
<!-- Introduction of new namespaces defined by this model -->
<namespaces>
<namespace uri="http://www.test.com/model/workflow/1.0"
prefix="lhwf" />
</namespaces>
<types>
<type name="lhwf:submitMyTask">
<parent>bpm:startTask</parent>
<properties>
<property name="lhwf:actionRequired">
<type>d:text</type>
<mandatory>true</mandatory>
<multiple>false</multiple>
</property>
</properties>
</type>
</types>
</model>
The share-config-custom.xml file looks like this
<alfresco-config>
<config evaluator="string-compare" condition="activiti$activitiAdhoc2">
<forms>
<form>
<field-visibility>
<show id="bpm:workflowDescription" />
<show id="lhwf:actionRequired" />
<show id="bpm:workflowDueDate" />
` <show id="bpm:workflowPriority" />
<show id="bpm:assignee" />
<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.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="Title">
<control template="/org/alfresco/components/form/controls/textarea.ftl">
<control-param name="style">width: 95%</control-param>
</control>
</field>
<field id="lhwf:actionRequired" label="Action Required" set="info" />
<field id="bpm:workflowDueDate" label-id="workflow.field.due" set="info">
<control template="/org/alfresco/components/form/controls/date.ftl">
<control-param name="showTime">false</control-param>
<control-param name="submitTime">false</control-param>
</control>
</field>
<field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info">
<control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
</field>
<field id="bpm:assignee" label-id="workflow.field.assign_to" 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>
Thanks in advance
O
I would recommend the following.
<show id="lhwf:actionRequired" force="true"/>
Can you please share the bpmn file here?
I need to set a value from a text field on my start form and then pull this information on several other tasks. To do this, I'm using an aspect and trying to send the data up to the execution variable, and then pull it down.
The problem is that I cannot send the value from the start form to the execution variable. As it is now, Share will just say that the workflow cannot be started.
I am using Alfresco 4.2.f Community edition.
The start event is defined in the BPMN as follows:
<startEvent id="start" name="Start Delivery Ticket Workflow" activiti:initiator="initiatorUserName" activiti:formKey="deliveryTicketWorkflow:start">
<documentation>Project Manager initiates workflow. A customer purchase order is provided, along with the specific line items for the delivery ticket.</documentation>
<extensionElements>
<activiti:executionListener class="org.alfresco.repo.workflow.activiti.listener.ExecutionListener" event="start">
<activiti:field name="script">
<activiti:string><![CDATA[
execution.setVariable('deliveryTicketWorkflow_requestdetailstext', task.getVariable('deliveryTicketWorkflow_requestdetailstext'));;
]]></activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
</startEvent>
The relevant parts of my model are:
<type name="deliveryTicketWorkflow:start">
<parent>bpm:startTask</parent>
<properties />
<associations />
<overrides />
<mandatory-aspects>
<aspect>deliveryTicketWorkflow:requestdetails</aspect>
</mandatory-aspects>
</type>
[...]
<aspect name="deliveryTicketWorkflow:requestdetails">
<properties>
<property name="deliveryTicketWorkflow:requestdetailstext">
<title>Specific Details</title>
<type>d:text</type>
<mandatory>true</mandatory>
<multiple>false</multiple>
</property>
</properties>
</aspect>
In the config:
<config condition="deliveryTicketWorkflow:start" evaluator="task-type">
<forms>
<form>
<field-visibility>
<show id="packageItems"/>
<show id="deliveryTicketWorkflow:requestdetailstext"/>
<show id="transitions"/>
</field-visibility>
<appearance>
<set appearance="title" label-id="Prepare Delivery Ticket" id="info"/>
<field set="info" id="packageItems"/>
<field set="info" label-id="Request Details" id="deliveryTicketWorkflow:requestdetailstext">
<control template="/org/alfresco/components/form/controls/info.ftl"/>
</field>
<set id="response"/>
<field set="response" id="transitions"/>
</appearance>
</form>
</forms>
</config>
[...]
<config condition="activiti$deliveryTicketWorkflow" evaluator="string-compare">
<forms>
<form>
<field-visibility>
<show id="bpm:workflowPriority"/>
<show id="packageItems"/>
<show id="deliveryTicketWorkflow:requestdetails"/>
<show id="transitions"/>
<show id="deliveryTicketWorkflow:approveRejectOutcome"/>
</field-visibility>
<appearance>
<set appearance="title" label-id="Request Delivery Ticket" id="info"/>
<field set="info" label-id="workflow.field.priority" id="bpm:workflowPriority">
<control template="/org/alfresco/components/form/controls/workflow/priority.ftl"/>
</field>
<field set="info" id="packageItems"/>
<field set="info" label-id="Request Details" id="deliveryTicketWorkflow:requestdetails">
<control template="/org/alfresco/components/form/controls/textarea.ftl"/>
</field>
<set id="response"/>
<field set="response" id="approveRejectOutcome">
<control template="/org/alfresco/components/form/controls/workflow/activiti-transitions.ftl"/>
</field>
<field set="response" id="transitions"/>
</appearance>
</form>
</forms>
</config>
I have seen at least one question here that was similar, but the answers were stating to use task listeners for the start form. I'm not sure at all how that is intended to function, because it seems like a start task isn't a "true" task and can only use ExecutionListeners. The difference should be small, but it seems that any reference to "task" in the start task will either cause a failure or just have no affect at all. Becasue I can't use task.getVariableLocal() to get the value, I don't see what to give to execution.setVariable() as the value.
In my experience, all values of aspects and properties in a start task are automatically copied to the executionContext and are already available for future tasks.
Try removing the executionlistener in your BPMN, you shouldnt need that. Then try making a starttasklistener on your subsequent task that copyies the value from your execeutioncontext into this task. It should work fine.
Getting the var back from your executioncontext in your subsequent task should work like this:
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="language" stringValue="groovy" /
<activiti:field name="script">
<activiti:string><![CDATA[
System.out.println(execution.getVariable("deliveryTicketWorkflow_requestdetailstext"));
if (execution.getVariable("deliveryTicketWorkflow_requestdetailstext") != null){
task.setVariableLocal('deliveryTicketWorkflow_requestdetailstext', execution.getVariable("deliveryTicketWorkflow_requestdetailstext"));
}]]>
</activiti:string>
</activiti:field>
</activiti:taskListener>
This is a long shot but in your share form, your custom field is using the info control:
I believe you need there to be a regular field there, the info field is to display text, AFAIK, it doesn't include an input field and won't send anything to the workflow start.
I deleted the existing process and renamed the id to a custom id MyActivitiParallelReview. Redeployed this process through activiti admin console. I defined the below config in share-config-custom.xml.
<config evaluator="string-compare" condition="activiti$MyActivitiParallelReview">
<forms>
<form>
<field-visibility>
<show id="bpm:workflowDescription" />
<show id="bpm:workflowDueDate" />
<show id="bpm:workflowPriority" />
<show id="bpm:assignees" />
<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">
<control template="/org/alfresco/components/form/controls/date.ftl">
<control-param name="showTime">false</control-param>
<control-param name="submitTime">false</control-param>
</control>
</field>
<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" label-id="workflow.field.requiredApprovePercent" set="assignee">
<control template="/org/alfresco/components/form/controls/percentage-approve.ftl">
<control-param name="minValue">1</control-param>
<control-param name="maxValue">100</control-param>
</control>
</field>
<field id="bpm:assignees" label-id="workflow.field.reviewers" 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>
However when I start the workflow from share I am seeing error 10300034 Failed to start workflow activiti$MyActivitiParallelReview:1:1959
Please assist me what might be the issue ?
Got it working, when I renamed the id, I forgot to rename the digarm element with the new id. I corrected it.