cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow API, JavaScript, Web Scripts

snig
Champ in-the-making
Champ in-the-making
Hi

I am trying to initiate a workflow by Workflow JavaScript API, it is called in a Web Script.

Here is the code snippet… It is pretty much exactly same as the examples provided in various Alfresco Wiki pages…

   var workflow = actions.create("start-workflow");
   workflow.parameters.workflowName = "jbpm$wf:job";
   workflow.parameters["bpm:workflowDescription"] = desc;
   workflow.parameters["bpm:context"] = objectSpace;
   //workflow.parameters["bpm:assignee"] = person;
   var futureDate = new Date();
   futureDate.setDate(futureDate.getDate() + 7);
   workflow.parameters["bpm:workflowDueDate"] = futureDate;
   workflow.execute(objectSpace);

It fails saying "Internal Server Error".

However, I tried to debug it by the JavaScript Debugger. It throws a NullPointerException at line
   workflow.execute(objectSpace);

Not sure what is the issue.

Is there any documentation what exactly workflow.execute does? And what should be the parameter passed into this?

Thanks,
Snig.
2 REPLIES 2

snig
Champ in-the-making
Champ in-the-making
Any Replies please…  :?
Counting on you guys…

davidc
Star Contributor
Star Contributor
objectSpace is not defined anywhere.

For the 'start-workflow' action, the parameter to execute() is the node (e.g. document) you want to route through the workflow.

So, as long as you have a handle onto a document you can pass that.  Within a web script, that may be driven by a url parameter, search etc.