OData Query to retrieve records based on record Guid

To retrieve the record based on Guid, below is the small code snippet to use.

function getRecordFromGuid() {
    var resultData = null;
    var uniqueId =RecordGuid;
    var oDataEndpointUrl = "http://yourservername/XRMServices/2011/OrganizationData.svc/";
    oDataEndpointUrl += "new_tempSet?&";

    oDataEndpointUrl += "$select=new_name&$filter=new_tempid eq guid'" + uniqueId + "'";
    $.ajax({
        type: "GET",
        url: oDataEndpointUrl,
        //data: jsonAccount,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        beforeSend: function (XMLHttpRequest) {
            //Specifying this header ensures that the results will be returned as JSON.
            XMLHttpRequest.setRequestHeader("Accept", "application/json");
        },
        success: function result(data) {
            resultData = data.d.results;

        },
        async: false,
        error: function (xhr, textStatus, errorThrown) {
            errorCallback(this._errorHandler(xhr));

        }
    });

    if (resultData != null)
        return resultData;
    else
        return null;
}





You may like below posts

Improving MS CRM Performance

Performance Center in MS CRM 2013

date and time field behavior in MS CRM

Upsert in MSCRM

Locking mechanism in MS CRM

Ticker Symbol Field in MS CRM

Themes in MS CRM

Enable Tracing in MS CRM

Calculated Field in Dynamics CRM 2015

IME Mode in MS CRM

No comments:

Post a Comment

Featured Post

Improving MS CRM Performance

Performance on MS CRM is always a crucial thing and we may follow different ways to achieve the performance thing. Below is the one more a...