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