Using REST endpoints with json2 are the simplest way to retrieve data in CRM 2011. The code is clean and simple. Here is a sample retrieve request
retrieveAccountsReq.open("GET", getRESTUrl() +
"/new_postcodeSet?$top=20&$select=new_name,new_Country,new_Suburb,new_State,new_postcodeId&$filter=new_name
eq ('" + postcode + "')", true);
The above request is used to retrieve the custom entity (new_postcode) dataset where new_name is equal to postcode.
To get the dataset names for all the entities use http://servername:portnumber/organization name/XRMServices/2011/OrganizationData.svc/
The result will look like this
To get the fieldnames for an entity you can use http://servername:portnumber/organization name/XRMServices/2011/OrganizationData.svc/entitySet
The result will look like this
You can even paste the query in the browser and check the result of the query. The following query will display all the records with postcode 2010.
The result will look like this
Conclusion
REST endpoints are the best way to retrieve data on client site. You can even see the result of the query in the browser.
Happy Programming……..
Nice info, however I can't seem to get any custom entities to work (even using the prefix)
ReplyDeleteWhat's the error message? I am using custom entity new_postcode in the above examle.
DeleteSingh, i created a custom field called "field_A" for contacts, noticed it appeared in the ContactExtensionBase table. How do i get "field_A" from this table.
DeleteFor AccountBase look at the code (it works perfectly)
var filterx = '/AccountSet?';
var filterz = "$select=AccountNumber,AccountId&$filter=AccountId eq (guid'" + accid + "')";
now to get "field_A" from ContactExtensionBase i go like this
var filterx = '/ContactExtensionSet?';
var filterz = "$select=new_CustomerID&$filter=ContactId/Id eq (guid'" + accid + "')";
i get error 404 for XMLHttpRequest status.
Thank you.
Got the Solution
DeleteUsed ContactSet instead of ContactExtensionSet
var filterx = '/ContactSet?';
var filterz = "$select=new_CustomerID&$filter=ContactId eq (guid'" + accid + "')";
Is it possible to query using lookup text value in crm jscript?
ReplyDeleteMicrosoft Dynamics CRM training will help you manage and prioritize your business goals, customize.we teach MS Dynamics CRM training and class available at Hyderabad.
ReplyDelete