1

This is for SP2010. I'm trying to implement a "launch" button for a workflow, inline in a SharePoint list. I do not want the users to go to the "Workflows" page, they want to click a button while viewing the desired list item in a list view.

I can render a button within a list row/column using jQuery, and I've got a URL that will launch the correct list workflow for the given item. The challenge facing me is that the ID of the workflow changes whenever the workflow is edited, as the previous ID now points to a previous workflow.

Can I query (either via REST or some other web service) for a list workflow's ID, given the workflow's name?

0

We did this for 2013, do not know of all code works in 2010 as well

(update: this code does NOT work in 2010)

Can I add a start workflow link to a column in a list view?

It runs by Item-ID and Workflow Name

function startWorkflow(itemID, wfName) {
    function __startWorkflow() {
        var ctx = new SP.ClientContext.get_current(),
            wfsManager = SP.WorkflowServices.WorkflowServicesManager.newObject(ctx,ctx.get_web()),
            wfSubscriptions = wfsManager.getWorkflowSubscriptionService().enumerateSubscriptionsByList(_spPageContextInfo.pageListId);
        ctx.load(wfSubscriptions);
        ctx.executeQueryAsync(function () {
            var wfsEnum = wfSubscriptions.getEnumerator();
            while (wfsEnum.moveNext()) {
                var wfSubscription = wfsEnum.get_current();
                if (wfSubscription.get_name() === wfName) {
                    wfsManager.getWorkflowInstanceService().startWorkflowOnListItem(wfSubscription,itemID,new Object());
                    var note=SP.UI.Notify.addNotification('Init Workflow: '+wfName+' on item: '+itemID, false);
                }
            }
        });
    }
    if (SP.WorkflowServices) {
        __startWorkflow();
    } else {
        var script = document.createElement("script");
        script.src = "/_layouts/15/sp.workflowservices.js";
        script.onload = __startWorkflow;
        document.head.appendChild(script);
    }
}
startWorkflow(12,'WFNewLink');

iWF

  • 1
    Unfortunately, sp.workflowservices.js is not available in SP 2010. Shame, too, because it looks perfect otherwise. – Alan M Oct 23 '15 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.