Quantcast
Channel: Forum CRM Development
Viewing all articles
Browse latest Browse all 1000

CRM 2011: JavaScript oData Function

$
0
0

Please take a look at the following few lines of code and see if you find anything wrong here.  

I'm trying to create a JavaScript function to retrieve an entity I created for configuration settings.  In that entity I have created fields called dhi_value and dhi_key. In my other code such as plugins and web services, I am able to hit CRM and use the KEY to return the VALUE.  My entity is called dhi_adminconfiguration.

The code runs but I continue to get an error that says that the entity or field is not found.  So I suspect my oData path is incorrect, probably the filter.  However, the names of the entity and fields are correct.  I suspect I've got something simply here that I a missing, as I have not tried hit CRM from JavaScript like this before, so I probably have some simple error that I cannot see.

Any suggestions, thoughts, ideas, etc. are much appreciated.

Best regards,

Jon

RetrieveAccount = function () {

		var oDataPath = Xrm.Page.context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc/dhi_adminconfiguration?$select=dhi_key,dhi_value&$filter=dhi_key eq 'CRM_WebService_Path'";
		alert(oDataPath);
		var retrieveReq = new XMLHttpRequest();
		retrieveReq.open("GET", oDataPath, false);
		retrieveReq.setRequestHeader("Accept", "application/json");
		retrieveReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
		retrieveReq.onreadystatechange = function () { retrieveReqCallBack(this); };
		retrieveReq.send();
	}

	retrieveReqCallBack = function (retrieveReq) {
		alert('callback:' + retrieveReq );
		if (retrieveReq.readyState == 4 /* complete */) {
			alert('ready');
//            var retrieved = this.parent.JSON.parse(retrieveReq.responseText).d;
//            alert(retrieved);
//            var value = retrieved.results[0].dhi_value;
//            alert(value);
		 }
	}


Jon Gregory Rothlander


Viewing all articles
Browse latest Browse all 1000

Trending Articles



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