Find the best tutors and institutes for MS Dynamics CRM

Find Best MS Dynamics CRM Training

Please select a Category.

Please select a Locality.

No matching category found.

No matching Locality found.

Outside India?

Search for topics

How to use FetchXml in CRM Web API

Jayakar Reddy
13/06/2018 0 0

Here I am going to show how to use FetxhXML query to get the results from CRM Web API.  below example shows how to get logged in user Security roles.

function getRoles(token) {
var req = new XMLHttpRequest();
var fetch = “<fetch version=’1.0′ output-format=’xml-platform’ mapping=’logical’ distinct=’true’>” +
“<entity name=’role’>” +
“<attribute name=’name’ />” +
“<attribute name=’businessunitid’ />” +
“<attribute name=’roleid’ />” +
“<order attribute=’name’ descending=’false’ />” +
“<link-entity name=’systemuserroles’ from=’roleid’ to=’roleid’ visible=’false’ intersect=’true’>” +
“<link-entity name=’systemuser’ from=’systemuserid’ to=’systemuserid’ alias=’ad’>” +
“<filter type=’and’>” +
“<condition attribute=’systemuserid’ operator=’eq-userid’ />” +
“</filter>” +
“</link-entity>” +
“</link-entity>” +
“</entity>” +
type: “GET”,
contentType: “application/json; charset=utf-8”,
datatype: “json”,
url: Xrm.Page.context.getClientUrl() + “/api/data/v8.2/roles?fetchXml=” + fetch,
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader(“OData-MaxVersion”, “4.0”);
XMLHttpRequest.setRequestHeader(“OData-Version”, “4.0”);
XMLHttpRequest.setRequestHeader(“Accept”, “application/json”);
XMLHttpRequest.setRequestHeader(“Prefer”, “odata.include-annotations=\”*\””);
async: false,
success: function (data, textStatus, xhr) {
var results = data;
for (var i = 0; i < results.value.length; i++) {
var roleid = results.value[i][“roleid”];
var roleName = results.value[i][“name”];
error: function (xhr, textStatus, errorThrown) {
alert(textStatus + ” ” + errorThrown);

0 Dislike
Follow 1

Please Enter a comment


Other Lessons for You

What is M.S.Project ?
MICROSOFT PROJECT contains project work and project groups, schedules and finances.Microsoft Project permits its users to line realistic goals for project groups and customers by making schedules, distributing...

Creating/Setting/Admin Center of Dynamics CRM - Office 365
Introduction Dynamics 365 is a cloud service launched by Microsoft. It combines its Cloud CRM and ERP services into a single offering.Microsoft Dynamics 365 is the next generation of intelligent business...

Sumit Gupta | 28/05/2018

0 0

Plugins In Microsoft Dynamics CRM
Microsoft Dynamics CRM plug-ins are one of the most commonly used and powerful approaches to extending the application. A plug-in for CRM is custom code, written and compiled in .Net, that is “triggered”...

Sumit Gupta | 12/10/2017

0 0

Architecture of Business Process Flow in Dynamics 365
Business Process Flows till CRM 2016 Every record with Business process flow till Microsoft Dynamics 2016 , used to have two attributes specific to them:- Process ID : Process Stage ID. To set a desired...

Sumit Gupta | 21/09/2017

0 0

Developing integration utility with Microsoft Dynamics
We all know that the evolution of the technologies has been tremendous in couple of years, leading to development and implementation of the systems in more compact and well integarted way. Each day a...

Sumit Gupta | 25/11/2016

1 0

Looking for MS Dynamics CRM Training?

Find best MS Dynamics CRM Training in your locality on UrbanPro.

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you

Find Best MS Dynamics CRM Training?

Find Now » is India's largest network of most trusted tutors and institutes. Over 25 lakh students rely on, to fulfill their learning requirements across 1,000+ categories. Using, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 6.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more