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

Trying to retrieve custom entity using javascript but getting [Object Object] on alertbox

$
0
0

 I am trying to return Price of an custom entity RegistrationFee. But alert box shows  [Object Object]

What am I doing wrong here? Any help will be greatly appreciated. Thanks. 

Code:

function GetDetails() {
LookupFieldObject = Xrm.Page.data.entity.attributes.get('fund_registrationfees');
if (LookupFieldObject.getValue() != null) {
var EntityId = LookupFieldObject.getValue()[0].id;
EntityId = EntityId.replace('{', '').replace('}', '');
if (EntityId != null) {
oDataPath = Xrm.Page.context.getServerUrl() + "/xrmservices/2011/organizationdata.svc";
RetrieveRecord(EntityId, oDataPath);
}
}
}
function RetrieveRecord(Id, ODataPath) {
try {
var retrieveReq = new XMLHttpRequest();
retrieveReq.open("GET", ODataPath + "/fund_registrationfeeSet(guid'" + Id + "')", true);
retrieveReq.setRequestHeader("Accept", "application/json");
retrieveReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
retrieveReq.onreadystatechange = function () {
retrieveReqCallBack(this);
}
retrieveReq.send();
}
catch (err) {
var text = "There was an error on this page.\n\n";
text += "Error description: " + err.message + "\n\n";
text += "Click OK to continue.\n\n";
alert(text);
}
}
function retrieveReqCallBack(retrieveEntityReq) {
var PrefixText = ""
if (retrieveEntityReq.readyState == 4) {
retrieveEntityReq.onreadystatechange = null;
alert(retrieveEntityReq.status);
if (retrieveEntityReq.status == 200) {
var retrievedEntity = JSON.parse(retrieveEntityReq.responseText).d;

alert(retrievedEntity.hasOwnProperty("fund_Price"));
alert(retrievedEntity.fund_Price);


}
}
}


Viewing all articles
Browse latest Browse all 79901

Trending Articles



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