cancel
Showing results for 
Search instead for 
Did you mean: 

Error Start workflow via JavaScript

ruymesquita
Champ in-the-making
Champ in-the-making
I can't get start a Workflow via Web Script.

I created the file workflow.get.js:


var nodeId = args.nodeid; //fdadc86f-d996-472d-8267-850a63573b02
var workflowName = args.w; //jbpm$wf:adhoc
var document = search.findNode("workspace://SpacesStore/" + nodeId);
var workflowAction = actions.create("start-workflow");
workflowAction.parameters.workflowName = workflowName;
workflowAction.parameters["bpm:workflowDescription"] = "Please edit: " + document.name;
workflowAction.parameters["bpm:assignees"] = [people.getPerson("admin"), people.getPerson("admin")];
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflowAction.parameters["bpm:workflowDueDate"] = futureDate;
workflowAction.execute(document);

workflow.get.desc.xml

<webscript>
  <shortname>Start Workflow</shortname>
  <description>Testando Start Workflow</description>
  <url>/workflow?nodeid={idfile}&amp;&amp;w={namewf}</url>
  <format default="html">argument</format>
  <authentication>admin</authentication>
  <transaction>required</transaction>
</webscript>
and workflow.get.html.ftl
The ${args.w} started!

when I click http://localhost:8080/alfresco/service/workflow?nodeId=fdadc86f-d996-472d-8267-850a63573b02&w=jbpm$w... return the error

Exception: org.alfresco.error.AlfrescoRuntimeException - 08200041 TypeError: Cannot read property "name" from null 
(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Workflow/workflow.get.js#7)
  
org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:469)
  
Exception: org.alfresco.scripts.ScriptException - 08200042 Failed to execute script '/Workflow/workflow.get.js
(in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': 08200041 TypeError: Cannot read
property "name" from null (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Workflow/workflow.get.js#7)
  
org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:183)
  
Exception: org.springframework.extensions.webscripts.WebScriptException - 08200035 Wrapped Exception (with status template):
08200042 Failed to execute script '/Workflow/workflow.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)'
: 08200041 TypeError: Cannot read property "name" from null (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Workflow/
workflow.get.js#7)
  
org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:742)

Anybody help me?
1 REPLY 1

rwetherall
Confirmed Champ
Confirmed Champ
Hi,


ScriptNode findNode(string noderef)
Returns a single ScriptNode as specified by the string form of the NodeRef for that node, null is returned if the search failed.

So from the error presented it looks like the node reference you are searching for does not exist.

Perhaps you could use the Node Browser in the Explorer client to double check that node reference being passes exists?

Cheers,
Roy