Posts

Showing posts from March, 2019

Retrieve Multiple through fetch XML using Web API

Following is a detail sample code to retrieve multiple records using fetchXml query using Web API in Dynamics CRM. /* entityPlurarName: entityPlurarName is the plural entity logical name of entity e.g for account it is accounts. for opportunity it is opportunities fetchXml: fetchXml return:- entity collections object */ function executeFetchXml(entityPlurarName, fetchXml) { var data = null; var req = new XMLHttpRequest(); req.open('GET', Xrm.Page.context.getClientUrl() + "/api/data/v8.1/" + entityPlurarName + "?fetchXml=" + encodeURIComponent(fetchXml), false); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-type", "application/json; charset=utf-8"); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.send(); if (req.readyState === 4) { if (req.st...