Last active
August 29, 2015 14:05
-
-
Save vman/8c40e6e52b089eb098ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment