AnsweredAssumed Answered

Starting a workflow by webscript

Question asked by sihnu on Jan 29, 2015
Latest reply on Jan 30, 2015 by sihnu

I've been practicing with a web script that is supposed to take workflow definition name as a parameter and start a workflow of that definition. Here is my code:

var definition,

if (url.templateArgs['name'] === null) {
   status.code = 400;
   status.message = "A name must be provided.";
   status.redirect = true;
} else {
   name = url.templateArgs['name'];

definition = workflow.getDefinitionByName(name);
definition.startWorkflow(new Array());

I'm don't want to set any properties or package items at this point. All I want is to start a workflow but I get an error:

<blockquote>"org.springframework.extensions.webscripts.WebScriptException - 00290014 Wrapped Exception (with status template): 00290080 Failed to execute script '\/startWorkflow.get.js (in repository store workspace:\/\/SpacesStore\/Company Home\/Data Dictionary\/Web Scripts Extensions)': null",</blockquote>

when I'm calling the webscript. I debugged the java code behind this and I can see the null pointer error occurs at this point (method public JscriptWorkflowPath startWorkflow(ScriptNode workflowPackage, Object properties) at class: JscriptWorkflowDefinition):

Serializable context = workflowParameters.get(WorkflowModel.PROP_CONTEXT);
if (context == null)
    workflowParameters.put(WorkflowModel.PROP_CONTEXT, workflowPackage.getNodeRef());

workflowPackage is null. It's supposed to be null because I am not passing any documents. To get rid of this problem context should not be null. So I should set context as a property. The problem is I don't have any idea what is this context supposed to be. Could anyone help how to figure out what the context is supposed to be for me or some other way to solve the problem?

Thanks in advance…