2016-07-19 34 views
0

我無法通過Web腳本啓動工作流程。錯誤通過JavaScript啓動工作流程

我創建的文件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> 

和workflow.get.html.ftl

The ${args.w} started! 

當我點擊http:// localhost:8080/alfresco/service/workflow?nodeId = fdadc86f-d996-472d-8267-850a63573b02 & w = jbpm $ wf:adhoc返回錯誤

06190076 Wrapped Exception (with status template): 06190474 Failed to execute script '/triggerworkflow.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts)': 06190473 Can't find method org.alfresco.repo.jscript.ScriptAction.execute(org.mozilla.javascript.Undefined). (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts)#11)

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?

回答

0

你的問題是你要調用的參數在同一個地方一兩件事,不同的事情又在另一個:

var nodeId = args.nodeid; //fdadc86f-d996-472d-8267-850a63573b02 
var workflowName = args.w; //jbpm$wf:adhoc 

VS

<url>/workflow?nodeid={idfile}&amp;&amp;w={namewf}</url> 

你需要得到那些同意!我建議,給你似乎已經從客戶端使用,改變你的webscript描述符URL來匹配你用什麼,要的網址:

<url>/workflow?nodeid={nodeid}&amp;w={w}</url> 

您還應該添加邏輯來檢查該節點確實給存在 - search.findNode can return null所以你應該檢查在繼續之前(例如,給予404如果沒有找到)

此外,您還可以使用utils.getNodeFromString(String)如果你寧願

+0

你能解釋我,如果使用 ** ** workflow.get.js VAR 工作流程= actions.create( 「啓動工作流」); workflow.parameters.workflowName =「activiti $ TrainerEmpanelment」; workflow.parameters [「bpm:assignee」] = people.getPerson(「admin」); workflow.parameters [「initiator」] = people.getPerson(「admin」); var today = new Date(); var duedate = today.getDate()+ 1; workflow.parameters [「bpm:workflowDueDate」] = duedate; workflow.execute(document); workflow.get.desc.xml文件的網址是什麼 – Paul

+0

您可能不想要.desc.xml文件的URL - 通常只有在瀏覽可用的web腳本列表時才需要。如果您希望URL調用Web腳本,那麼無論您在說明文件中的「」標籤中輸入了什麼內容!如果這太多了,我建議你要麼購買一份「專業Alfresco」(幾年前,但webscript的東西仍然是一樣的),或參加一個Alfresco培訓課程 – Gagravarr

+0

我已經改變了URL在' .desc.xml文件保存並轉到外部web腳本再次點擊webscript我得到錯誤>「06190085包裝異常(狀態模板):06190498無法執行腳本'/triggerworkflow.get.js(在存儲庫存儲工作區中://SpacesStore/Company Home/Data Dictionary/Web Scripts)':missing; before statement(/triggerworkflow.get。js(在倉庫工作空間中:// SpacesStore/Company Home/Data Dictionary/Web Scripts)#6)「 – Paul

0

請嘗試使用此代碼來開始你的工作流程, 用此代碼替換您的代碼workflow.get.js並更改所有屬性根據您的要求。

function startWorkflow() 
{ 
    var workflowAction = workflow.getDefinitionByName("activiti$test_wf"); 
    var package= workflow.createPackage(); 

    var wfparams = new Array(); 
    wfparams["model_prefix:req_props_name"] = value2; 

    wfparams["bpm:assignee"] = people.getPerson("ADMIN"); 
    workflowAction.startWorkflow(package, wfparams); 
    } 

} 

startWorkflow();