我想以編程方式啓動工作流程。所以寫了一個web腳本。使用alfresco java腳本API或通過web腳本啓動工作流程
執行腳本:
function startWorkflow()
{
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "activiti$alfGroupReview";
workflow.parameters["bpm:workflowDescription"] = "Please review ";
workflow.parameters["bpm:groupAssignee"] = people.getGroup("GROUP_site_collaborators");;
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(document);
return ;
}
對於上面的腳本,我得到錯誤「的文件沒有定義」。我指的是https://forums.alfresco.com/en/viewtopic.php?f=34&t=42677和http://livinginjava.blogspot.in/2008/10/starting-alfresco-workflow-using.html鏈接。
所以我更新我的腳本:
function startWorkflow()
{
var nodeRef = "workspace://SpacesStore/25285e6c-2995-49fe-aa50-1270cefc806a";
var docNode = search.findNode(nodeRef);
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "activiti$alfGroupReview";
workflow.parameters["bpm:workflowDescription"] = "Please review ";
workflow.parameters["bpm:groupAssignee"] = people.getGroup("GROUP_aloha_collaborators");;
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflow.parameters["bpm:workflowDueDate"] = futureDate;
workflow.execute(docNode);
return ;
}
這裏,nodeRef:是文檔庫中文檔的參考。
現在,新的錯誤是:
500 Description: An error inside the HTTP server which prevented it from fulfilling the request.
Message: 06270056 Wrapped Exception (with status template): 06270273 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/justransform/startWF.get.js': null
Exception: org.alfresco.scripts.ScriptException - 06270273 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/justransform/startWF.get.js': null
org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:195)
在此先感謝。
你肯定你不能得到的節點傳遞到腳本作爲參數?如果沒有,你確定這是查找節點的正確方法嗎? – Gagravarr 2012-07-27 14:35:34
我可以通過節點作爲參數。但是,當我測試時,我使用硬編碼節點參考。我對工作流程很陌生,甚至不知道nodeRef是否需要啓動工作流程。謝謝你的回覆 – mahesh 2012-07-27 15:07:31
如果你想做一個評論工作流程,那麼你需要noderef來指定人們應該評論的內容! – Gagravarr 2012-07-27 15:29:45