-1

Can we start Sharepoint Designer site Workflow from javascript button click?

Analyst
  • 3
  • 2

2 Answers2

1

For SharePoint 2013 workflow:

function StartWF() {  
            $.ajax({  
                url: _spPageContextInfo.siteAbsoluteUrl + "/_api/SP.WorkflowServices.WorkflowInstanceService.Current/StartWorkflowOnListItemBySubscriptionId(subscriptionId='BB20B816-2AEF-4299-B6BF-43910578BA8F',itemId=' " + $("#drpItem option:selected").text() + "')",  
                type: "POST",  
                contentType: "application/json;odata=verbose",  
                headers: {  
                    "Accept": "application/json;odata=verbose",  
                    "X-RequestDigest": $("#__REQUESTDIGEST").val()  
                },  
                success: function (data) {  
                    alert('Workflow Trigger Successfully');  
                },  
                error: function (data) {  
                    alert("Error");  
                }  
            });  

        }

Detailed information in this thread

Lee
  • 5,305
  • 1
  • 6
  • 12
0

I remember you can do this. Should be something line __workflowStart when executing postback. You can take a look at this link for more details. https://social.msdn.microsoft.com/Forums/office/en-US/817a4366-939c-47c6-bfbc-375a00dfcaf2/genfireserverevent-workflowstart-and-parameters?forum=sharepointcustomizationlegacy

dwrt:GenFireServerEvent is translated into JavaScript with __doPostBack, by the way.