cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow Share Form Configuration Not Rendering few Custom Properties.

satheeshkumar
Champ in-the-making
Champ in-the-making
Hi All,

I have created a customWorkFlow model and created custom workflow and configured the form in "share-config-custom.xml" with my custom properties, but still it  doesn't retrive the values which I set during the workflow creation.

My custom WorkFlow Model.
<?xml version="1.0" encoding="UTF-8"?>
<!– Definition of new Model –>
<model name="hcwf:workFlowModel"
   xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>
   <description>Custom Workflow Model</description>
   <author>Satheesh Kumar</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/dictionary/1.0" prefix="d"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <namespaces>
      <namespace uri="http://www.myorg.com/model/workflow/1.0"
         prefix="hcwf" />
   </namespaces>

   <types>
      <type name="hcwf:addNewProductTask">
         <parent>bpm:startTask</parent>
         <properties>            
            <property name="hcwf:sourceNodeRef">
               <type>d:noderef</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="hcwf:destinationParentNodeRef">
               <type>d:noderef</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="hcwf:packageInformation">
               <type>d:text</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="hcwf:workDescription">
               <type>d:text</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
            </property>
         </properties>
      </type>
      
      <type name="hcwf:activitiReviewTask">
            <parent>bpm:activitiOutcomeTask</parent>
            <properties>
                <property name="hcwf:reviewOutcome">
                    <type>d:text</type>
                    <default>Reject</default>
                    <constraints>
                        <constraint type="LIST">
                            <parameter name="allowedValues">
                                <list>
                                    <value>Approve</value>
                                    <value>Reject</value>
                                </list>
                            </parameter>
                        </constraint>
                    </constraints>
                </property>
            </properties>              
            <overrides>
                <property name="bpm:packageItemActionGroup">
                    <default>read_package_item_actions</default>
                </property>
                <property name="bpm:outcomePropertyName">
                    <default>{http://www.myorg.com/model/workflow/1.0}reviewOutcome</default>
                </property>
            </overrides>
        </type>
       
        <type name="hcwf:activitiReviseTask">
            <parent>bpm:activitiOutcomeTask</parent>
            <properties>
                <property name="hcwf:reviseOutcome">
                    <type>d:text</type>
                    <default>Abort</default>
                    <constraints>
                        <constraint type="LIST">
                            <parameter name="allowedValues">
                                <list>
                                    <value>Re-Submit</value>
                                    <value>Abort</value>
                                </list>
                            </parameter>
                        </constraint>
                    </constraints>
                </property>
            </properties>              
            <overrides>
                <property name="bpm:packageItemActionGroup">
                    <default>read_package_item_actions</default>
                </property>
                <property name="bpm:outcomePropertyName">
                    <default>{http://www.myorg.com/model/workflow/1.0}reviseOutcome</default>
                </property>
            </overrides>
        </type>
      
      
   </types>

   
</model>



Java codes where I am setting the values for my custom workflow properties,

public class HCCustomModel {

   //Model NameSpace Constants.
   public static final String NAMESPACE_HC_CONTENT_MODEL  = "http://www.myorg.com/model/content/1.0";
   public static final String NAMESPACE_HC_WORKFLOW_MODEL  = "http://www.myorg.com/model/workflow/1.0";
   
   //Workflow related tasks.   
   public static final QName QNAME_HC_SOURCENODEREF = QName.createQName(NAMESPACE_HC_WORKFLOW_MODEL,"sourceNodeRef");
   public static final QName QNAME_HC_DEST_PARENTNODEREF = QName.createQName(NAMESPACE_HC_WORKFLOW_MODEL,"destinationParentNodeRef");
   public static final QName QNAME_HC_WORKDESCRIPTION = QName.createQName(NAMESPACE_HC_WORKFLOW_MODEL,"workDescription");
   public static final QName QNAME_HC_PACKAGEINFORMATION = QName.createQName(NAMESPACE_HC_WORKFLOW_MODEL,"packageInformation");
   
}

//WorkFlow Specific Codes,
NodeRef wfPackage = getServiceRegistry().getWorkflowService().createPackage(destProductCodeFolderNodeRef);
Map<QName, Serializable> workFlowProps = new HashMap<QName, Serializable>();
ChildAssociationRef childAssoc = getServiceRegistry().getNodeService().getPrimaryParent(destProductCodeFolderNodeRef);
NodeRef productRootNodeRef = HCCustomUtils.getRootNodeRef(HCConstants.PRODUCT_LIBRARY);
NodeRef destinationNodeRef = HCCustomUtils.getChildFolderNodeRef(productRootNodeRef, destProductTypeFolder, false);
workFlowProps.put(WorkflowModel.ASSOC_PACKAGE, wfPackage);
workFlowProps.put(WorkflowModel.PROP_CONTEXT, childAssoc.getParentRef());
workFlowProps.put(HCCustomModel.QNAME_HC_SOURCENODEREF, destProductCodeFolderNodeRef);
workFlowProps.put(HCCustomModel.QNAME_HC_DEST_PARENTNODEREF, destinationNodeRef);       
workFlowProps.put(HCCustomModel.QNAME_HC_WORKDESCRIPTION, "HC workDescription");
workFlowProps.put(HCCustomModel.QNAME_HC_PACKAGEINFORMATION, "HC packageInformation");
workFlowProps.put(HCCustomModel.QNAME_BPM_WORK_FLOW_DESCRIPTION, "Content Added for the Product Type \""+destProductTypeFolder+"\"");
workFlowProps.put(HCCustomModel.QNAME_BPM_COMMENT, "Please review the uploaded content.");
workFlowProps.put(HCCustomModel.QNAME_BPM_SEND_EMAIL, true);

try{
   HCCommonUtils.triggerWorkFlow("activiti$addNewProduct", workFlowProps);
}
catch(Exception e){
   throw new AlfrescoRuntimeException("There was an error while initiating workflow named \"activiti$myAddNewProduct\". "+e.getMessage());
}


My CustomWorkflow BPMN(its pretty Big but still I have show it completely here)

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="addNewProduct" name="Add New Product WorkFlow" isExecutable="true">
    <startEvent id="startevent1" name="Start" activiti:formKey="hcwf:addNewProductTask"></startEvent>
    <userTask id="reviewTask" name="Review Product Content Task" activiti:candidateGroups="GROUP_PRODUCT_MANAGER" activiti:formKey="hcwf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof hcwf_sourceNodeRef != 'undefined') task.setVariable('hcwf_sourceNodeRef', hcwf_sourceNodeRef);
                  if (typeof hcwf_destinationParentNodeRef != 'undefined') task.setVariable('hcwf_destinationParentNodeRef', hcwf_destinationParentNodeRef);
                  if (typeof hcwf_workDescription != 'undefined') task.setVariable('hcwf_workDescription', hcwf_workDescription);
                  if (typeof hcwf_packageInformation != 'undefined') task.setVariable('hcwf_packageInformation', hcwf_packageInformation);
                  if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);

                  logger.log("hcwf_sourceNodeRef:"+hcwf_sourceNodeRef);
                  logger.log("hcwf_destinationParentNodeRef:"+hcwf_destinationParentNodeRef);
                  logger.log("hcwf_workDescription:"+hcwf_workDescription);
                  logger.log("hcwf_packageInformation:"+hcwf_packageInformation);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if(task.getVariableLocal('hcwf_reviewOutcome') == 'Approve') {
                     execution.setVariable('hcwf_approved', true);
                     logger.log("task.getVariableLocal('hcwf_reviewOutcome')"+task.getVariableLocal('hcwf_reviewOutcome'));
                  } else {
                     execution.setVariable('hcwf_approved', false);
                     logger.log("task.getVariableLocal('hcwf_reviewOutcome')"+task.getVariableLocal('hcwf_reviewOutcome'));
                  }
                  execution.setVariable('hcwf_manager',person);
                  execution.setVariable('bpm_workflowDescription', task.getVariable('bpm_workflowDescription'));
                  execution.setVariable('bpm_description', task.getVariable('bpm_description'));
                  execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="reviseTask" name="Revise Product Content Task" activiti:assignee="${initiator.properties.userName}" activiti:formKey="hcwf:activitiReviseTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);
                     logger.log("Revise Task, Create -  bpm_workflowDescription: "+ bpm_workflowDescription);
                  logger.log("Revise Task, Create -  bpm_description: "+ bpm_description);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if(task.getVariableLocal('hcwf_reviseOutcome') == 'Re-Submit') {
                     execution.setVariable('hcwf_resubmit', true);
                     logger.log("task.getVariableLocal('hcwf_reviseOutcome')"+task.getVariableLocal('hcwf_reviseOutcome'));
                  } else {
                     execution.setVariable('hcwf_resubmit', false);
                     logger.log("task.getVariableLocal('hcwf_reviseOutcome')"+task.getVariableLocal('hcwf_reviseOutcome'));
                  }
                  execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="reviewTask"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="reviewTask" targetRef="approveTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${hcwf_approved == true}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="reviewTask" targetRef="reviseTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${hcwf_approved == false}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow5" sourceRef="reviseTask" targetRef="abortTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${hcwf_resubmit == false}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow6" sourceRef="reviseTask" targetRef="resubmitTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${hcwf_resubmit == true}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow7" sourceRef="approveTask" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow8" sourceRef="abortTask" targetRef="endevent1"></sequenceFlow>
    <userTask id="resubmitTask" name="Review the Resubmitted Product Content Task" activiti:assignee="${hcwf_manager.properties.userName}" activiti:formKey="hcwf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[if(task.getVariableLocal('hcwf_reviewOutcome') == 'Approve') {
                     execution.setVariable('hcwf_approved', true);
                     logger.log("task.getVariableLocal('hcwf_reviewOutcome')"+task.getVariableLocal('hcwf_reviewOutcome'));
                  } else {
                     execution.setVariable('hcwf_approved', false);
                     logger.log("task.getVariableLocal('hcwf_reviewOutcome')"+task.getVariableLocal('hcwf_reviewOutcome'));
                  }
                  execution.setVariable('bpm_workflowDescription', task.getVariable('bpm_workflowDescription'));
                  execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow9" sourceRef="resubmitTask" targetRef="approveTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${hcwf_approved == true}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow10" sourceRef="resubmitTask" targetRef="reviseTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${hcwf_approved == false}]]></conditionExpression>
    </sequenceFlow>
    <serviceTask id="approveTask" name="Approve Task" activiti:class="org.hc.workflows.ApproveRejectExecution"></serviceTask>
    <serviceTask id="abortTask" name="Abort Task" activiti:class="org.hc.workflows.ApproveRejectExecution"></serviceTask>
  </process>
  //Removed the BPMN Diagram
</definitions>


Form configuration for my custom workflow review task,

<config evaluator="task-type" condition="hcwf:activitiReviewTask">
      <forms>
         <form>
            <field-visibility>
              
               <show id="packageItems" force="true" />
              
               <show id="hcwf:workDescription" force="true" /> //This property is still retrieved with empty value, though I set in my Java class
               <show id="hcwf:packageInformation" force="true" /> //This property is still retrieved with empty value, though I set in my Java class
               <show id="hcwf:reviewOutcome" force="true" />
              
               <show id="bpm:comment" force="true" />
              
               <!– <show id="transitions" /> –>
              
            </field-visibility>
            <appearance>
               <set id="productPackage" appearance="title" label-id="workflow.product.package.details" />
               <set id="workDesc" appearance="title" label-id="workflow.product.work.description" />
               <set id="packageInfo" appearance="title" label-id="workflow.product.package.information" />
               <set id="review" appearance="title" label-id="workflow.product.review" />
               <set id="comment" appearance="title" label-id="workflow.product.review.comment" />

              
             
               <field id="packageItems" set="productPackage" />
              
              
               <filed id="hcwf:workDescription" set="workDesc">
               <!– <control template="/org/alfresco/components/form/controls/info.ftl">
               </control> –>
               </filed>
               <filed id="hcwf:packageInformation" set="packageInfo">
               <!– <control template="/org/alfresco/components/form/controls/textarea.ftl"></control> –></filed>              
               <field id="hcwf:reviewOutcome" set="review" />
               <field id="bpm:comment" set="comment">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
            </field>
                            
            </appearance>
         </form>
      </forms>
    </config>


The properties

  <show id="hcwf:workDescription" force="true" /> and <show id="hcwf:packageInformation" force="true" />
are retrieved with empty values, can you please let me know why these two property values are not showing in my review form?
2 REPLIES 2

sihnu
Champ in-the-making
Champ in-the-making
Aren't you missing the properties in type "hcwf:activitiReviewTask"? You have set them in start task but they are missing from the review task. I'm not sure if you need to define them again but I do think so. Perhaps worth of a try at least.

muralidharand
Star Contributor
Star Contributor
As I understood your question, you wanted to carry some values from the start workflow page to edit task pages.
If this is correct, you need a change a bit on the model. You need to group, these kind of fields into aspect and make then as mandatory aspects.



      <type name="myCoWF:productCreationStartTask">
            <title>Product Creation Start Task</title>
            <parent>bpm:startTask</parent>           
            <mandatory-aspects>
                <aspect>myCoWF:productRequestFields</aspect>
            </mandatory-aspects>           
        </type>


        <type name="myCoWF:productCreationReviewTask">
            <title>Product Creation Review Task</title>
            <parent>bpm:activitiOutcomeTask</parent>
            <properties>           
                <property name="myCoWF:oproductCreationReviewOutcome">
                    <type>d:text</type>
                    <default>Reject</default>
                    <constraints>
                        <constraint ref="myCoWF:reviewOutcomeOptionConstraint" />
                    </constraints>  
                </property>
            </properties>            
            <overrides>
                <property name="bpm:packageActionGroup">
                    <default>add_package_item_actions</default>
                </property>
                <property name="bpm:packageItemActionGroup">
                    <default>edit_package_item_actions</default>
                </property>
                <property name="bpm:outcomePropertyName">
                    <default>{myCoWF.workflowModel}productCreationReviewOutcome</default>
                </property>               
            </overrides>      
            <mandatory-aspects>
                <aspect>myCoWF:productRequestFields</aspect>
            </mandatory-aspects>                
        </type>

……
<aspects>
    <aspect name="myCoWF:productRequestFields">
      <properties>
         <property name="myCoWF:productName">
            <title>Product Name</title>
            <type>d:text</type>
            <mandatory>true</mandatory>
            <multiple>false</multiple>
         </property>
         <property name="myCoWF:productTitle">
            <title>Product Title</title>
            <type>d:text</type>
            <mandatory>false</mandatory>
            <multiple>false</multiple>
         </property>
         <property name="myCoWF:productDescription">
            <title>Product Description</title>
            <type>d:text</type>
            <mandatory>false</mandatory>
            <multiple>false</multiple>
         </property>
   </aspect>
</aspects>            
      



In the share-form-config.xml, just include the fields, as normal.
This way, you can share the values across tasks within the workflow.

Please let me know, if you need additional information on this.