2. You can pass URL encoded FetchXML as a query to the entity set corresponding to the root entity of the query using the fetchXml
query string parameter to return the results from the Web API.
3. Generate FetchXML queries through Advanced Find.
In the below example, FetchXML is formatted to be used by the Web API service endpoint. You can either do it by storing the FetchXML in a variable and encoding the string with the encodeURI function native to JavaScript or do it directly as shown below.
Click here to use FetchXML to query data in the plugin.
var
parameter = {};
parameter["new_opportunityid"] = id.toString().replace("{", "").replace("}", "");
"<entity name='new_academiccontent'>" +
"<attribute name='new_academiccontentid' />" +
"<attribute name='new_name' />" +
"<attribute name='statecode' />" +
"<order attribute='new_name' descending='false' />" +
"<filter type='and'>" +
"<condition attribute='new_opportunityid' operator='eq' uitype='opportunity' value='{" + parameter["new_opportunityid"] + "}' />" +
"</filter>" +
"</entity>" +
"</fetch>";
var query = "new_academiccontents?fetchXml=" + encodeURI(fetchxml);
Xrm.WebApi.retrieveMultipleRecords("new_academiccontent", query).then( function success(result) { for (var i = 0; i < result.entities.length; i++) { console.log(result.entities[i]); } // perform additional operations on retrieved records }, function (error) { console.log(error.message); // handle error conditions } );
Thank you ...