Skip to content

Instantly share code, notes, and snippets.

@vman
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vman/8c40e6e52b089eb098ae to your computer and use it in GitHub Desktop.
Save vman/8c40e6e52b089eb098ae to your computer and use it in GitHub Desktop.
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