cancel
Showing results for 
Search instead for 
Did you mean: 

not able to run advanced workflow using api

unknown-user
Champ on-the-rise
Champ on-the-rise
I try to run a custom worflow using alfresco api (not javascript). I have a parmeter bpm:assignees (multiple assignees) that i m not able to set . This is my code:
Action workflow = actionService.create("start-workflow");
workflow.setParameterValue(workflowName ,"jbpm$wf:myworkflow");
workflow.setParameterValue("bpm_workflowDescription", description);
workflow.setParameterValue("bpm_assignees",listPerson);
workflow.execute(nodeRef);

where listPerson is an array (or a list i have tried both) of personRef;
My worfflow failed when it try to execute the transition where there is the action ForEachFork.

thanks for any help
6 REPLIES 6

davidc
Star Contributor
Star Contributor
What error are you getting?

kimquy76
Champ in-the-making
Champ in-the-making
I'm trying to do the samething and keep getting error.

Below is my code
  var workflow = actions.create("start-workflow");
    workflow.parameters.workflowName = "jbpm$wf:submit";
    workflow.parameters["bpm:workflowDescription"] = "blah";
   workflow.parameters["bpm:initiator"] = "user1";
    workflow.parameters["bpm:assignee"] = "user2"; 
    var futureDate = new Date();
    futureDate.setDate(futureDate.getDate() + 7);
    workflow.parameters["bpm:workflowDueDate"] = futureDate;

var store = avm.lookupStore(args.q);
var node = store.lookupNode("/ROOT/childfolder/" + args.file);

  workflow.execute(node);

Below is the error I'm getting:
org.alfresco.service.cmr.repository.InvalidNodeRefException - Node does not exist

mikef
Champ in-the-making
Champ in-the-making
Looks like you trying to launch a workflow on a using a Webscript and
var node = store.lookupNode("/ROOT/childfolder/" + args.file); is not returning a node.

You should use the JavaScript debugger to walk through the code and test that args.q and args.file are being passed correctly and then check that the store and node are being returned.

You can enable the debugger from the Web Script Index page:

http://<YOURHOST>:8080/alfresco/service/index

Please note this will open the debugger on the server, you therefore need to be on the server to work with it. Please see http://wiki.alfresco.com/wiki/JavaScript_API#Alfresco_Javascript_Debugger for more info.

kimquy76
Champ in-the-making
Champ in-the-making
when I tried to print out the path of the node, I do get value returned correctly, therefore I'm sure I do get the node being returned correctly.

Do you know how I would pass the node into workflow.execute function?  Should I pass the whole node like workflow.execute(node) or should I pass in the path such as workflow.execute(note.path) or should it be something else?

kimquy76
Champ in-the-making
Champ in-the-making
I've tried workflow.execute(node.nodeRef), and get the following error:
org.alfresco.service.cmr.repository.InvalidNodeRefException - Node does not exist:

Why would a node does not exist, but its path is availalble?

dhalupa
Champ on-the-rise
Champ on-the-rise
You might check the source of following class org.alfresco.repo.workflow.StartWorkflowActionExecuter (Repository project) as an example of how to properly start advanced workflow from java

Kind regards,

Denis