Retrieve site workflow id using JavaScript Object model in SharePoint Online

This SharePoint jsom tutorial explains, how we can retrieve site workflow id using JSOM (javascript object model) in SharePoint online. Here we have developed one site workflow using visual studio 2015 as a SharePoint hosted add-in and we have attached to the host website.

Here we were adding the below code inside a script editor web part inside a web part page in SharePoint online (Download PDF for FREE).

Here we have the workflow name as “TestWorkflow” and through the below code we can retrieve the workflow id from SharePoint online site.

If you are new to JSOM SharePoint Online, you can read Working with JavaScript object model (jsom) in SharePoint 2013 or SharePoint Online.

<input type=”button” id=”btnSubmit” value=”Get Workflow ID” /><br/>

<script src=”” ></script>
$(function () {
function bindButtonClick() {
$(“#btnSubmit”).on(“click”, function () {

function getWorkflowId() {
var clientContext = new SP.ClientContext.get_current();
this.workflows = clientContext.get_web().get_workflowAssociations();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

function onQuerySucceeded(sender, args) {
var enumerator = this.workflows.getEnumerator();
var workflow = enumerator.get_current();
if(workflow.get_name() == “TestWorkflow”)

function onQueryFailed(sender, args) {

You may like following SharePoint designer workflow tutorials:

Hope this SharePoint Online JSOM tutorial helps how to retrieve site workflow id using JavaScript object model (jsom) in SharePoint Online Office 365.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

  • >