04-16-2014 04:39 PM
<serviceTask id="incomingClientDocument" name="Client Workflow" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
<extensionElements>
<activiti:field name="script">
<activiti:string><![CDATA[
logger.log('incomingClientDocument-START');
var clientNodeRef = execution.getVariable('rtcm_clientAssoc');
var dueDate = execution.getVariable('bpm_workflowDueDate');
// Here, the second workflow starts…
rtTaskService.startIncomingClientDocument(clientNodeRef, bpm_package, dueDate);
logger.log('incomingClientDocument-END');
]]></activiti:string>
</activiti:field>
</extensionElements>
</serviceTask>
public void startIncomingClientDocument(final ScriptNode clientNode, final ScriptNode packageNode, final Date dueDate) {
logger.info("Start Incoming Client Document Workflow");
NodeService nodeService = this.getServiceRegistry().getNodeService();
WorkflowService workflowService = this.getServiceRegistry().getWorkflowService();
ClientEntity clientEntity = new ClientEntity(getServiceRegistry(), clientNode.getNodeRef());
// Create a package that contains the items of the source package
NodeRef packageNodeRef = workflowService.createPackage(null);
if (packageNode != null) {
for (ChildAssociationRef childRef : nodeService.getChildAssocs(packageNode.getNodeRef()))
nodeService.addChild(packageNodeRef, childRef.getChildRef(), WorkflowModel.ASSOC_PACKAGE_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "incomingClientDocument"));
}
WorkflowDefinition workflowDefinition = workflowService.getDefinitionByName("activiti$IncomingClientDocument");
Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
parameters.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "Incoming Client Document");
parameters.put(WorkflowModel.PROP_WORKFLOW_DUE_DATE, dueDate);
parameters.put(WorkflowModel.PROP_DUE_DATE, dueDate);
parameters.put(WorkflowModel.ASSOC_GROUP_ASSIGNEE, clientEntity.getGroupAuthorityName());
parameters.put(WorkflowModel.ASSOC_PACKAGE, packageNodeRef);
parameters.put(ClientRelatedContentModel.ASSOC_CLIENT, clientNode.getNodeRef());
workflowService.startWorkflow(workflowDefinition.getId(), parameters);
}
Error while completing sub process of execution ProcessInstance[92626]
05-19-2014 04:21 AM
WorkflowPath path = workflowService.startWorkflow(workflowDefinition.getId(), parameters);
String wfPathId = path.getId();
List<WorkflowTask> wfTasks = workflowService.getTasksForWorkflowPath(wfPathId);
if (wfTasks.size() == 0)return;
WorkflowTask wfStartTask = wfTasks.get(0);
workflowService.endTask(wfStartTask.getId(), null);
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.