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

Forum Post: RE: CRM 2013 - Lookup primary account

$
0
0

I'd suggest hitting the REST/Odata endpoint you this sort of thing:

Reference URL: Use the REST Endpoint for Web Resources

Example script that grabs a phone number from a contact record and sets it to another form field:

var contact = Xrm.Page.getAttribute("contactid").getValue(); if (contact === null) return;  var serverUrl = Xrm.Page.context.getClientUrl(); var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/ContactSet(guid'" + contact[0].id + "')?$select=MobilePhone";  var req = new XMLHttpRequest(); req.open("GET", oDataSelect, false); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json;charset=utf-8"); req.onreadystatechange = function () {     if (req.readyState === 4) {         if (req.status === 200) {             var retrieved = JSON.parse(req.responseText).d;             Xrm.Page.getAttribute("new_phone").setValue(retrieved.MobilePhone);         }     } }; req.send(); 

Viewing all articles
Browse latest Browse all 123975

Latest Images

Trending Articles



Latest Images

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