Alfresco社区版-5.1.x如何使用webscript(java或javascript)启动工作流程?

时间:2016-07-14 10:42:36

标签: javascript java alfresco-share alfresco-webscripts

Alfresco社区5.1.x,我创建了自定义工作流程,我需要通过webscripts(java或javascript)触发吗?因为我是露天新手,请帮我一步?

2 个答案:

答案 0 :(得分:0)

js-api也许可以帮到你:https://github.com/Alfresco/alfresco-js-api

 //Call a GET on a Web Scripts available at the following URIs:          http://127.0.01:8080/alfresco/service/mytasks

 this.alfrescoJsApi.webScript.executeWebScript('GET', 'mytasks').then(function (data) {
   console.log('Data received form http://127.0.01:8080/alfresco/service/mytasks' + data);    
}, function (error) {
   console.log('Error' + error);
});

//Call a GET on a Web Scripts available at the following URIs: http://127.0.01:8080/share/service/mytasks

this.alfrescoJsApi.webScript.executeWebScript('GET', 'mytasks', null, 'share').then(function (data) {
   console.log('Data received form http://127.0.01:8080/share/service/mytasks' + data);    
}, function (error) {
   console.log('Error' + error);
});

//Call a GET on a Web Scripts available at the following URIs: http://127.0.01:8080/share/differentServiceSlug/mytasks

this.alfrescoJsApi.webScript.executeWebScript('GET', 'mytasks', null, 'share', 'differentServiceSlug').then(function (data) {
   console.log('Data received form http://127.0.01:8080/share/differentServiceSlug/mytasks' + data);    
}, function (error) {
   console.log('Error' + error);
});

答案 1 :(得分:0)

你可以像这样使用AJAX调用你的repo webscript

 var mylink=encodeURI("/webscript-url?parameter1="+value1);

                    Alfresco.util.Ajax.request({

                              url: Alfresco.constants.PROXY_URI + mylink,

                              method: Alfresco.util.Ajax.GET,

                    });

将此代码放入repo webscript的JS文件中,并根据您的要求更改所需的属性。

function startWorkflow()
{
    var value2 = args["parameter1"];// you can get parameter by this
    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();