Hi,
I have created new customized entity namely account technology details, it store technical information of account. for this the primary field is new_accounttechnologydetailsId and new_accounttechnologydetails is the entity. I want to check whether record exists in this entity or not before creating record. Please find below script for this. I do not know it executes until alert("2") and the retrieveResult.status is always 200 even the record not exists in this entity. It displays unable to get property for any fields when I try to display. I verified the filed name but it is correct. and retrieved.results.length is always 0 even there is record or not. Please help to find solution to check the account id before change account id.

var accountID= Xrm.Page.getAttribute("new_accountid").getValue()[0].id;
var context = Xrm.Page.context;
var serverUrl = context.getServerUrl();
var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
var retrieveResult = new XMLHttpRequest();
retrieveResult.open("GET", ODataPath + "/new_accounttechnologydetailsSet?$select=OwnerId&$filter=new_accounttechnologydetailsId eq guid'" + accountID + "'", false);
retrieveResult.setRequestHeader("Accept", "application/json");
retrieveResult.setRequestHeader("Content-Type", "application/json; charset=utf-8");
retrieveResult.send();
if (retrieveResult.readyState == 4 )
{
if (retrieveResult.status == 200)
{
alert("2");
var retrieved = JSON.parse(retrieveResult.responseText).d;
alert(retrieved.results.length);
var tact = retrieved.results[0].OwnerId;
alert(tact);
}
}
*This post is locked for comments
I have the same question (0)