In what path should I set the aspect name, constraint name? What file is it? Below is the content of the link above.
———————————————————————————————————————————————————————— Creation of new workflow
This section describes how to create new workflow that depending on whether task was approved or rejected is going to add appropriate aspect to all the files attached to the workflow. Let’s call the aspect ‘workflowOutcomeAspect’ and allow it to have two values: ‘approved’ or ‘rejected’. The definition of new aspect is presented below.
Following that let’s modify the initial workflow (‘Review and Approve’) to add ‘workflowOutcomeAspect’ to all the child nodes of package node and set property ‘workflowOutcome’ of that aspect to ‘approved’ or ‘rejected’ depending on user action. To note, ‘Review and Approve’ workflow is one of the standard workflows available with Alfresco deployment. The package is available in JavaScript under ‘bpm_package’ variable and its children can be obtained by invocation of ‘bpm_package.children’. More information about creation and management of workflows can be found in my post Creation of workflow in Alfresco using Activiti step by step.
<userTask id="approved" name="Document 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> if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority; </activiti:string> </activiti:field> </activiti:taskListener> <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener"> <activiti:field name="script"> <activiti:string> if (bpm_package != null && bpm_package.children != null) { var i = 0; for (i = 0; i < bpm_package.children.length; i++) { var document = bpm_package.children; document.addAspect("wf:workflowOutcomeAspect"); document.properties["wf:workflowOutcome"] = "approved"; document.save(); } } </activiti:string> </activiti:field> </activiti:taskListener> </extensionElements> <humanPerformer> <resourceAssignmentExpression> <formalExpression>${initiator.exists() ? initiator.properties.userName : 'admin'}</formalExpression> </resourceAssignmentExpression> </humanPerformer> </userTask>
<userTask id="rejected" name="Document Rejected" activiti:formKey="wf:rejectedTask" > <documentation> The document was reviewed and rejected. </documentation> <extensionElements> <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener"> <activiti:field name="script"> <activiti:string> if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority; </activiti:string> </activiti:field> </activiti:taskListener> <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener"> <activiti:field name="script"> <activiti:string> if (bpm_package != null && bpm_package.children != null) { var i = 0; for (i = 0; i < bpm_package.children.length; i++) { var document = bpm_package.children; document.addAspect("wf:workflowOutcomeAspect"); document.properties["wf:workflowOutcome"] = "rejected"; document.save(); } } </activiti:string> </activiti:field> </activiti:taskListener> </extensionElements> <humanPerformer> <resourceAssignmentExpression> <formalExpression>${initiator.exists() ? initiator.properties.userName : 'admin'}</formalExpression> </resourceAssignmentExpression> </humanPerformer> </userTask>