How can I set up a link in a list/library view to manually start a workflow (without the user seeing or going to the Start Workflow window)?
Hi Kimberly,
I have not yet had to do this, but I guess you can create the link with some variables. If you hover over a start button you will see the link that is executed...as shown in the image below.
You will get the long code at the end after "list=" by going to the List--> list settings and copying it from the url
And the rest should be quite easy. Let me know if you need more info.
Regards,
Francois
I have tried this, but the problem is that it always takes me to the Start Workflow page and what I want to do is just have the workflow automatically run when they click the link without the users having to press the "Start" button on that page.
Kim
Hi,
You can use SharePoint's client side rendering (jslink) to do this (see script below).
You'll need to edit it to point at the correct workflow and list name in startworkflowonlistitemcsr("Workflow Name", listitemid , "List Name"). The item ID has been set as the last column in the list view so it can be found, then just use the following script as your JS Link source:
(function () {
(window.jQuery || document.write('<script src="//ajax.aspnetcdn.com/ajax/jquery/jquery-1.10.0.min.js"></script>'));
var viewContext = {};
viewContext.Templates = {};
viewContext.Templates.Footer = "<div><input type='button' Value='Start Workflow on ID for Selected' onclick='StartWorkflowOnSelectedItems();'></div>";
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(viewContext);
})();
function StartWorkflowOnSelectedItems()
{
$('.s4-itm-selected').each(function(){
var listitemid = $(this).find('.ms-vb-lastCell')f0].innerText;
startworkflowonlistitemcsr("Workflow Name", listitemid , "List Name");
});
}
function startworkflowonlistitemcsr(wfName, itemId, listName) {
var associationData = '';
var webMethod = _spPageContextInfo.webAbsoluteUrl + '/_vti_bin/NintexWorkflow/Workflow.asmx';
var soap = "<?xml version=""1.0"" encoding=""utf-8""?>" +
"<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=""http://www.w3.org/2001/XMLSchema" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/">" +
"<soap:Body>" +
"<StartWorkflowOnListItem xmlns=""http://nintex.com">" +
"<itemId>" + itemId + "</itemId>" +
"<listName>" + listName + "</listName>" +
"<workflowName>" + wfName + "</workflowName>" +
"<associationData></associationData>" +
"</StartWorkflowOnListItem>" +
"</soap:Body>" +
"</soap:Envelope>";
$.ajax({
type: "POST",
url: webMethod,
beforeSend: function (xhr) { xhr.setRequestHeader("SOAPAction", "http://nintex.com/StartWorkflowOnListItem"); },
data: soap,
contentType: "text/xml; charset=utf-8",
dataType: "xml",
success: function (data) {
},
error: function (e) {
}
});
}
Jan
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.