触发Sharepoint 2013工作流程

时间:2020-03-23 17:56:31

标签: javascript sharepoint sharepoint-2013

我需要通过单击按钮来使用Sharepoint 2013触发工作流。因此,基本上使用类似“触发器”工作流程的东西来启动工作流程。触发的功能需要使用Javascript启动工作流。我找到了这个示例,但我无法使它正常工作,我认为它适用于Sharepoint 2013。

    function LoadScripts(){
    SP.SOD.executeFunc("sp.js", "SP.ClientContext" , function(){
        SP.SOD.registerSod('sp.workflowservices.js',  SP.Utilities.Utility.getLayoutsPageUrl('sp.workflowservices.js'));
        SP.SOD.executeFunc('sp.workflowservices.js', "SP.WorkflowServices.WorkflowServicesManager", StartSiteWorkflow);
    })    
}

    function StartSiteWorkflow(){
    var context = SP.ClientContext.get_current();

    var web = context.get_web();

    //Workflow Services Manager
    var wfServicesManager = new SP.WorkflowServices.WorkflowServicesManager(context, web);

    //Workflow Interop Service used to interact with SharePoint 2010 Engine Workflows
    var interopService = wfServicesManager.getWorkflowInteropService()

    //Initiation Parameters have to be in a plain JS Object.
    var initiationParameters = {
        FirstName: "Vardhaman",
        LastName: "Deshpande"
    };

    //Start the Site Workflow by Passing the name of the Workflow and the initiation Parameters.
    interopService.startWorkflow("My Workflow", null, null, null, initiationParameters);

    context.executeQueryAsync(function () {
        console.log("workflow started");
    },
    function (sender, args) {
        console.log(args.get_message());
    });
}

jQuery(document).ready(function () {
    LoadScripts();
});

0 个答案:

没有答案
相关问题