Here’s a snippet of code that I’ve used to create a shortcut from a list item form ribbon button to a workflow initiation form.
var workflow;
function SubmitForReview() {
var context = SP.ClientContext.get_current();
var web = context.get_web()
var list = web.get_lists().getById(parent.ctx.listName);
var workflows = list.get_workflowAssociations();
workflow = workflows.getByName("Submit For Review")
context.load(workflow);
context.executeQueryAsync(onSuccessMethod, onFailureMethod);
}
function onSuccessMethod(sender, args) {
var workflowUrl = '/_layouts/yourworkflow/initiation.aspx?List=' + parent.ctx.listName + '&ID=' + parent.ctx.ctxId + '&TemplateID=' + workflow.get_id() + '&Source=' + parent.ctx.listUrlDir;
parent.location.href = workflowUrl;
}
function onFailureMethod(sender, args) {
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
0 comments:
Post a Comment