How to start an Alfresco Workflow through Javascript adding a resource

断了今生、忘了曾经 提交于 2019-11-28 05:11:34

问题


Starting using a rule and a simple javascript in Alfresco is quite easy but i'm stuck on trying to start a workflow through javascript adding a resource.

My goal is to add the document (or documents) used to start the flow, so i can obtain a reference in the "OW_ATTACHMENTS" of the Alfresco BPM of the Alfresco WorkDesk. I've tried many times with the bpm:workflowpagckage or bpm:package with no luck....help!

Edit:

  function startWorkflow(name,docNode)
{    
    var workflow = actions.create("start-workflow");
    workflow.parameters["bpm:workflowPackage"] = docNode;
    workflow.parameters.workflowName = "activiti$AdHocactivitiTimer";
    workflow.parameters["bpm:assignee"] = people.getPerson("admin");
    workflow.parameters["bpm:workflowDescription"] = "test";
    workflow.parameters["bpm:workflowPriority"] = "2";
    workflow.parameters["bpm:sendEMailNotifications"] = true;
    workflow.parameters["initiator"] = people.getPerson("admin"); 
    var today = new Date();
    var duedate = today.getDate() + 1; 
    workflow.parameters["bpm:workflowDueDate"] = duedate;
    workflow.execute(document);
}

function main()
{    
    var docNode = search.findNode(document.nodeRef); 
    var name = document.name;  
        startWorkflow(name,docNode); 
}


main();

thanks!


回答1:


The bpm:package or bpm_package is not available before start. So what happens you're document is added to bpm_package.

And in your workflow you can access bpm_package as a variable. And with bpm_package.addNode(doc); you can add nodes.

These nodes can be found through search/childbynamepath/xpath etc.

If you don't use the action the other way is:

var workflowAction = workflow.getDefinitionByName('activiti$AdHocactivitiTimer');
var package= workflow.createPackage();
package.addNode(document);
workflowAction.startWorkflow(package, parameters);


来源:https://stackoverflow.com/questions/16156819/how-to-start-an-alfresco-workflow-through-javascript-adding-a-resource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!