Saturday, 24 December 2016

Use OData Query in ADXStudio

As we know Adxstudio Portal is now one of the most used Web Portal integrated with Dynamic CRM and one of the most common requirement and frequently asked question by developers is How to use retrieval query on Portal to fetch data from CRM.

One of the most common requirement on Portal is to auto populate data in entity forms fields based on lookup value.

For Example : As soon as user select customer in Customer lookup field, I want to auto populate selected customer entity data on case entity form fields (customer email, mobile phone, company name etc). Like this there might be so many requirement to fetch CRM data on portal conditionally.

Before going through the usage of OData in Adxstudio Portal first let us understand what is OData.

What is OData ?
OData is also referred as Open Data Protocol. Dynamic CRM mainly uses Windows Communication Foundation (WCF) data services framework to provide OData Endpoint which is nothing but a REST based data service. The address for the endpoint is:

https://{OrganizationRootUrl} /XRMServices/2011/OrganizationData.svc

How to use OData in Adxstudio Portal ?

I have been asked so many times for how to use OData Query in Adxstudio Portal,

Below are the steps to use OData query in adxstudio :-

Step 1 - Create Entity List in CRM with below mentioned configuration.

Name of Entity List, Entity Name, Website, View, OData Feed - Enabled,Entity Type Name, Entity Set Name, View





Step 2 -  Test OData.


Hit your portal url  on browser in below mentioned format.

<Portal Url>/_odata   -  This will give you all Entity list in which you have enabled OData Feeds.





Hit your portal url  on browser in below mentioned format.

<Portal Url>/_odata/<Entity Set Name>   -  This will give you the result of OData on browser.

Step 3 -  How to use OData in JavaScript (on Entity Form/Web Form/Entity List/Web Page/).


// Start Case Retrieval code

var GetResolvedCases = "~/_odata/cases?$filter=statuscode/Value eq 1";

or

var caseGuid = 'A237C638-F47B-E611-80F2-5065F38BF2F1';

var retrievebyGUID = "~/_odata/incidents?$filter=incidentid%20eq%20(guid%27" + caseGuid + "%27)";

$.ajax({
    type: "GET",
    url: GetResolvedCases,
    dataType: 'json'
}).done(function (json) {

    var CaseColl = json.value;

    // Get Case ticket number
    if (CaseColl[0].ticketnumber)
    {
        CaseId = CaseColl[0].ticketnumber;

    }
})
})

// Case Retrieval code End


Using above code you can get Case ticket number, if you are familiar with Dynamic CRM OData query then you can make query as per your requirement, or you can refer below link to know more about OData query syntax and uses.

Note : Refer below link for more details about how to write OData Query in CRM/Portal

https://msdn.microsoft.com/en-us/library/gg309461(v=crm.7).aspx


8 comments:

  1. How to insert the data using Odata Call in CRM Portals/Adxstudio

    ReplyDelete
  2. How to filter using the lookup text??

    eg: ?$filter=oki_preferredlanguage/Name eq (Text'English')

    ReplyDelete
  3. Well I really liked reading it. This post provided by you is very constructive for proper planning.
    python cloud development

    ReplyDelete

  4. Do you need Personal Loan?
    Business Cash Loan?
    Unsecured Loan
    Fast and Simple Loan?
    Quick Application Process?
    Approvals within 24-72 Hours?
    No Hidden Fees Loan?
    Funding in less than 1 Week?
    Get unsecured working capital?
    Contact Us At : gaincreditloan1@gmail.com
    Whatsapps +31-635-250-311 (WhatsApp Only)

    ReplyDelete
  5. I'm getting Object reference not set to an instance of an object.error has anyone experienced this ?

    ReplyDelete
  6. Avail this bargaining tool in your e-commerce storebargainingtool

    ReplyDelete
  7. Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to

    (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time.

    Contact him now and thank me later.

    ReplyDelete
  8. Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to

    (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time.

    Contact him now and thank me later.

    ReplyDelete

Blogger Widgets