REST Endpoints and jQuery is one of the good way to retreive record(s) from CRM 2011.
Step1 : You have to use the following jQuery files in to to your solution. they are
1. jquery-1.6.2.min.js (or use the latest version(recommended))
2. json2.js
Now..
Step2:
in CRM 2011 SDK we can see several good example. we will make use of them to set the lookup field on a custom entity.
| // Set lookup value of a field function retrieveContactId() { if (Xrm.Page.ui.getFormType() == 1) { // Get the CRM URL // Cater for URL differences between on premise and online if (serverUrl.match(/\/$/)) { // Specify the ODATA end point (this is the same for all CRM 2011 implementations) var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc"; // Specify the ODATA entity collection (this needs to be specific to your entity) // Specify the ODATA filter // Build the URL //Calls the REST endpoint //Specifying this header ensures that the results will be returned as JSON. success: function (data, textStatus, XmlHttpRequest) { //This function will trigger asynchronously if the Retrieve was successful error: function (XmlHttpRequest, textStatus, errorThrown) { //This function will trigger asynchronously if the Retrieve returned an error alert("My ajax call failed...."); |
|
|
|
|
| By calling the retrieveContactId function on ur script, it will automatically load the lookup filed on the form. |
| on the setLookup function you have to pass the lookup filed name that you want to fill the data. |
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
| |
| |
|
No comments:
Post a Comment