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

Forum Post: RE: JavaScipt - Populating fields from different entitys - possible?

$
0
0

Something like this - gets the phone number from a parent account:

function GetValue() {     var parent = Xrm.Page.getAttribute("parentcustomerid").getValue();      if (parent != null) { //Perform any basic checking to make sure we have a valid starting value         if (parent[0].entityType == "account") {              var accountId = parent[0].id;              var serverUrl = Xrm.Page.context.getClientUrl(); //If pre UR12 use getServerUrl()             var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'" + accountId + "')?$select=Telephone1";              var request = new XMLHttpRequest();             request.open("GET", oDataSelect, false); //false = synchronous, true = asynchronous             request.setRequestHeader("Accept", "application/json");             request.setRequestHeader("Content-Type", "application/json;charset=utf-8");             request.onreadystatechange = function () {                 if (request.readyState == 4) {                     if (request.status == 200) {                         var account = JSON.parse(request.responseText).d;                         Xrm.Page.getAttribute("new_parentaccountphone").setValue(account.Telephone1);                     }                 }             };             request.send();         }     } }; 

Viewing all articles
Browse latest Browse all 123975

Trending Articles



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