Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 123975

Forum Post: RE: How to upload values in a form based on another form of a different entity?

$
0
0

Here is my final code.

it is showing me the alerts but is not setting any value on the form

function getContactDetails()

{

   var lookUpObjectValue = Xrm.Page.getAttribute("inmate_lookupbookingscree").getValue();

   if ((lookUpObjectValue != null))

   {

       var lookuptextvalue = lookUpObjectValue[0].name;

       var lookupid = lookUpObjectValue[0].id;

       //alert(lookupid);

   var serverUrl = Xrm.Page.context.getServerUrl();

   //The XRM OData end-point

   var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";

   //var odataSetName = "ContactSet";

   var odataSelect = serverUrl + ODATA_ENDPOINT + "/" + "(guid'" + lookupid + "')";

   //alert(odataSelect);

   $.ajax({

       type: "GET",

       contentType: "application/json; charset=utf-8",

       datatype: "json",

       url: odataSelect,

       beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },

       success: function (data, textStatus, XmlHttpRequest) {

            var result_contact= data.d;

           //alert(result_contact.AccountNumber);

                       //replace the fields with the fields on your entity

Xrm.Page.getAttribute("inmate_firstname").setValue(result_contact.inmate_firstname);

Xrm.Page.getAttribute("inmate_lastname").setValue(result_contact.inmate_lastname);

       },

       error: function (XmlHttpRequest, textStatus, errorThrown) { alert('OData Select Failed: ' + odataSelect); }

   });

   }

  }


Viewing all articles
Browse latest Browse all 123975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>