Kwizcom Forms

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).

SharePoint deveopment training course

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=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js” ></script>
<script>
$(function () {
bindButtonClick();
});
function bindButtonClick() {
$(“#btnSubmit”).on(“click”, function () {
getWorkflowId();
});
}

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

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

function onQueryFailed(sender, args) {
alert(“Error”);
};
</script>

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.

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

About Bhawana Rathore

Hello Everyone!! I am Bhawana a SharePoint MVP and having about 8+ years of SharePoint experience as well as in .Net technologies . I have worked in all the versions of SharePoint from wss to Office 365. I have good exposure in Customization and Migration using Nintex, Metalogix tools . Now exploring more in SharePoint 2016 :) Hope here I can contribute and share my knowledge to the fullest. As I believe "There is no wealth like knowledge, and no poverty like ignorance"

View all posts by Bhawana Rathore →