web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to get workflow ID

(0) ShareShare
ReportReport
Posted on by 12,119 Moderator

Hi all,

I am using below code it worked for me:

var req = new XMLHttpRequest();

req.open("GET", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/WorkflowSet?$select=WorkflowId&$filter=Name eq 'test%20name' and  ParentWorkflowId eq null and StateCode/Value eq 1", true);

req.setRequestHeader("Accept", "application/json");

req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

req.onreadystatechange = function() {

   if (this.readyState === 4) {

       this.onreadystatechange = null;

       if (this.status === 200) {

           var returned = JSON.parse(this.responseText).d;

           var results = returned.results;

           for (var i = 0; i < results.length; i++) {

               var workflowId = results[i].WorkflowId;

           }

       } else {

           Xrm.Utility.alertDialog(this.statusText);

       }

   }

};

req.send();

 

I am wondering with ODATA. It will obsolete by Microsoft.

I have a work around for that I used below query but it is too complicated:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="workflow">
<attribute name="workflowid" />
<attribute name="name" />
<attribute name="category" />
<attribute name="primaryentity" />
<attribute name="statecode" />
<attribute name="createdon" />
<attribute name="ownerid" />
<attribute name="owningbusinessunit" />
<attribute name="type" />
<order attribute="name" descending="false" />
<filter type="and">
<condition attribute="type" operator="eq" value="1" />
<filter type="and">
<condition attribute="rendererobjecttypecode" operator="null" />
<filter type="or">
<condition attribute="category" operator="eq" value="0" />
<filter type="and">
<condition attribute="category" operator="eq" value="1" />
<condition attribute="languagecode" operator="eq-userlanguage" />
</filter>
<condition attribute="category" operator="eq" value="3" />
<condition attribute="category" operator="eq" value="4" />
</filter>
</filter>
<condition attribute="name" operator="eq" value="Clone Service Object" />
</filter>
</entity>
</fetch>

I think this query will impact on performance. Is there any other way to get workflow id?

 

Thank you

 

Regards,

 

AW

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    You can use web api. Download Crm Rest Builder tool. From here, you can vuild the same query using web api.

    hope it helps.

  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Ravi,

    I know that. It will give me above query that contains O DATA. I think you are not able to understand my Question.

    Thank you

    Regards,

    AW

  • Suggested answer
    Andreas Cieslik Profile Picture
    9,267 on at

    You can check results in Edge or Chrome very simple like with this...

    All workflow data:

    https://orgname.crm4.dynamics.com/api/data/v8.2/workflows

    All workflows with name and id:

    https://orgname.crm4.dynamics.com/api/data/v8.2/workflows?$select=name

    Workflows with Name equals 'GetResources':

    https://orgname.crm4.dynamics.com/api/data/v8.2/workflows?$select=name&$filter=name eq 'GetResources'

    Further query details:

    msdn.microsoft.com/.../gg334767.aspx

    The CRM REST builder tool helps you to configure and test your query:

    github.com/.../CRMRESTBuilder

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Abdul,

    I understand tbat your current query isworking fine but due to the deprecation of odata. you want to convert it to something supported?

    If this is correct then you can use web api instead of old odata endpoints as these are not going to deprecate.

  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Andreas

    Correct me if I am wrong. This will give me O DATA query. Am I right?

    Thank you

    Regards,

    AW

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Abdul,

    You can refer the below articles about the deprecation of 2011 endpoints.

    "As described in Microsoft Dynamics CRM 2011 endpoint, the Dynamics CRM 2011 endpoint is deprecated in favor of the Web API. Deprecating an endpoint is a pretty big deal, especially when the programming model is as different as it is with these two endpoints. We strongly encourage developers to use the Web API for applications that connect to CRM. For plug-ins and workflow assemblies you can continue to use the SDK assemblies. In coming releases we will modify these assemblies so that they will use the Web API instead of the 2011 endpoint."

    https://msdn.microsoft.com/library/dn281891.aspx#Crm2011Endpoint
    https://blogs.msdn.microsoft.com/crm/2016/06/17/deprecation-announcements-with-dynamics-crm-online-2016-update-1-and-microsoft-dynamics-crm-2016-service-pack-1/
    http://www.powerobjects.com/2016/03/28/the-new-crm-2016-web-api-is-here/

    As mentioned above, you can download the CRM Rest builder tool to build the Web API query to replace your existing old odata query.

    https://github.com/jlattimer/CRMRESTBuilder

    hope this helps.

  • Andreas Cieslik Profile Picture
    9,267 on at

    Hi Abdul,

    yes, the relatively new Web API is based on ODATA.

  • Verified answer
    ashlega Profile Picture
    34,477 on at

    Hi Abdul,

      the example Andreas gave you is using Web API:

    orgname.crm4.dynamics.com/.../workflows$select=name&$filter=name eq 'GetResources'

      In the broader sense, it's probably still ODATA.. but it's a different endpoint. All those warnings about the deprecation are relevant in the context of the endpoint - original ODATA endpoint(OrganizationData.svc) is deprecated now and will be removed at some point. Web API endpoint is what you should start using.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans