Last active
January 20, 2016 16:47
-
-
Save iOnline247/8341141 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
// Example itemUrl for Document: | |
// http://<site>/<DocLib>/doc7.docx | |
// Example itemUrl for Item: | |
// http://<site>/<customsite>/Lists/<ListName>/<ID>_.000 | |
function fireWorkflow ( itemUrl, workflowName, workflowParams ) { | |
workflowParams = workflowParams || "<root />"; | |
$().SPServices({ | |
operation: "GetTemplatesForItem", | |
item: itemUrl, | |
completefunc: function ( data, status ) { | |
var workflowGUID = "" | |
; | |
$(data.responseXML).find("WorkflowTemplates > WorkflowTemplate").each(function(i,e) { | |
var $this = $( this ) | |
; | |
// hard coded workflow name | |
if ( $this.attr("Name") === workflowName ) { | |
var guid = $this.find("WorkflowTemplateIdSet").attr("TemplateId"); | |
if ( guid ) { | |
workflowGUID = "{" + guid + "}"; | |
} | |
// Stops #each iteration | |
return false; | |
} | |
}); | |
$().SPServices({ | |
operation: "StartWorkflow", | |
item: itemUrl, | |
templateId: workflowGUID, | |
workflowParameters: workflowParams, | |
completefunc: function( data, status ) { | |
// Continue processing after workflow is fired. | |
} | |
}); | |
} | |
}); | |
} | |
fireWorkflow( "http://<site>/Lists/<listName>/<ID>_.000", "Workflow Name", "<Data><TestField>All up in your SharePoints.</TestField></Data>" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment