Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

How to get contact information by using ParentCustomerId from Opportunity entity

$
0
0

Hi,

I want to get department name from ContactSet from opportunity form by filtering ParentCustomerId. But I am getting retrieveResult.status = 400.  Please find below script and help me to find solution.

Calling from Opportunity form

var accountID= Xrm.Page.getAttribute("customerid").getValue()[0].id;  (Potential customer from Opportunity)
var context = Xrm.Page.context;
            serverUrl = context.getServerUrl(); 
            var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
            var retrieveResult = new XMLHttpRequest();
            retrieveResult.open("GET", ODataPath + "/ContactSet?$select=new_Department&$filter=ParentCustomerId eq guid'" + accountID + "'", false);
            retrieveResult.setRequestHeader("Accept", "application/json");
            retrieveResult.setRequestHeader("Content-Type", "application/json; charset=utf-8");
            retrieveResult.send();
            if (retrieveResult.readyState == 4 )
             alert("e");
               {
                if (retrieveResult.status == 200)
                   {
                    var retrieved = JSON.parse(retrieveResult.responseText).d;
                    alert(retrieved.results[0].new_Department)
    
                
                }
            }


Viewing all articles
Browse latest Browse all 46379

Trending Articles



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