cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow approvation grants

othlen
Champ in-the-making
Champ in-the-making
Hi everyone,

in my Alfresco 3.4.b i've a problem concerning workflows in Alfresco Share:

- An user starts a workflow on a document.
- He/she then selects another user as assignee of the review task.

Even if the review task is assigned to another user, the initiator of a workflow can perform the Approve or Reject transition on review task.
I think that allowing the initiator to perform transitions that should logically be done by the task assignee is not the correct behaviour of a meaningful workflow.

A valid workaround could be to change the workflow initiator to 'admin', but i don't know how to do it.

Any suggestions?

TIA

Oth
1 REPLY 1

pitzalis
Champ in-the-making
Champ in-the-making
Yo can start a workflow and set the initiatior as "admin",

by Javascript:

var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:serialreview";
workflow.parameters["bpm:workflowDescription"] = "Review for " + document.name;
workflow.parameters["bpm:description"] = "Review process init";
workflow.parameters["bpm:assignee"] = person;
workflow.parameters["initiator"] = people.getPerson("admin");
workflow.execute(document);

or by Java:

if( (workflowDefinition = workflowService.getDefinitionByName("jbpm$wf:serialreview")) != null ) {
   // Set workflow parameters
   NodeRef workflowNodeRef = workflowService.createPackage(null);
   nodeService.addChild(workflowNodeRef, documentNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "Advert within the workflow package"));
   parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowNodeRef);
   parameters.put(WorkflowModel.ASPECT_WORKFLOW_PACKAGE,workflowNodeRef);
   // … Workflow description
   parameters.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "Review for " + (String)nodeService.getProperty(documentNodeRef, ContentModel.PROP_NAME));
   // … Init task description
   parameters.put(WorkflowModel.PROP_DESCRIPTION, "Review process init");
   // … Set Workflow initiator as "admin" user
   parameters.put(QName.createQName(null, "initiator"), personService.getPerson("admin"));

   // Start workflow
   WorkflowPath wfPath = workflowService.startWorkflow(workflowDefinition.id, parameters);

  // task list
   List<WorkflowTask> wfTasks = workflowService.getTasksForWorkflowPath(wfPath.id);
   // throw an exception if no tasks where found on the workflow path
   if (wfTasks.size() == 0)   {
      logger.fatal("No workflow StartTask task found");
      throw new Exception();
      }

   try {
      WorkflowTask wfStartTask = wfTasks.get(0);   
      workflowService.endTask(wfStartTask.id, null);
   } catch (RuntimeException err) {
      logger.fatal("Failed endTask of StartTask task" + err.getMessage());
      throw err;
   }         
}

Bye,
GP