cancel
Showing results for 
Search instead for 
Did you mean: 

Start workflow from external application

alarocca
Champ in-the-making
Champ in-the-making
Hello, I would like to start a workflow from an external application using web service. I know that workflow service are not exposed as soap, so I am trying to call the start-workflow action (org.alfresco.repo.workflow.StartWorkflowActionExecuter).

I have the following problems:

  • That action defines only 3 parameters (workflowName, endStartTask, startTaskTransition). How can I specify other properties such as assignee, due date, priority, description)?

  • ActionUtils.executeAction requires parameters as HashMap<String, String>. If the above action allows to specify undefined parameters too, how can I specify values other than strings like nodeRef (assignee) or date?
Best regards,
Alessandro
5 REPLIES 5

danielsmith21
Champ in-the-making
Champ in-the-making
Someone please answer the OP. I'm having this same problem… Smiley Sad

alarocca
Champ in-the-making
Champ in-the-making
Solved. I created a new action. Basically is the same code of org.alfresco.repo.workflow.StartWorkflowActionExecuter. The new action converts string parameters to the proper types (date, person, int, …)

ventus85
Champ in-the-making
Champ in-the-making
Why you did not use "start-workflow"?
Why you had to convert the parameters?

Map<String, String> param = new HashMap<String, String>();
param.put("bpm:workflowDescription", "Something");
// etc etc
Reference reference = new Reference(store, null, null);
ActionUtils.executeAction(reference, "start-workflow", param);

Look for "org.alfresco.webservice.util.ActionUtils". This class contains this methods:
public static String executeAction(Reference ref, String actionName, Map<String, String> parameters)

:?:

alarocca
Champ in-the-making
Champ in-the-making
Compared to "start-workflow" my action allows to specify the workflow initiator (rather then the user credentials used to authenticate against the external application) and other custom fields.

One of these custom fields is a person (like the assignee). So I can provide the username as a string parameter from the external application using the ActionUtils.executeAction method. Then this value is used to retrieve the correct information and object type:

for (Map.Entry<String, Serializable> entry : paramValues.entrySet()) {
    String key = entry.getKey();

    QName qname = QName.createQName(entry.getKey(), namespaceService);

    if (key.equals("dnetwf:checker")) {
        value = personService.getPerson((String)entry.getValue());
        workflowParameters.put(qname, value);
    }
}

ventus85
Champ in-the-making
Champ in-the-making
One of these custom fields is a person (like the assignee). So I can provide the username as a string parameter from the external application using the ActionUtils.executeAction method.
Now I understand that.
Smiley Very Happy

If I use "start-workflow" and I run the code does not start the new workflow.  :cry:
But I do not give up!