Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

fetching lookup record attribute error in crm 2013

$
0
0

Hi,

I want to get specific attribute value of selected lookup record. When i run oDataURI in browser it displays bad request error.

https://bahrian/XRMServices/2011/OrganizationData.svc/new_datacentreSet?$filter=new_name eq'data1'&$select=new_Website,Content

userRequest.Status is "bad request" Please tell me correct code

here is my code

function getCurrentUserFullName()
{
var serverUrl;
var account=Xrm.Page.getAttribute("new_datacentre").getValue();
var accountid = account[0].name;
//accountid = accountid.replace('{', '').replace('}', '');
alert(accountid);
if (Xrm.Page.context.getClientUrl !== undefined)
{
alert("2");
serverUrl = Xrm.Page.context.getClientUrl();
}
else
{
serverUrl = Xrm.Page.context.getServerUrl();
}
alert("3");
   var oDataURI = serverUrl
        + "/XRMServices/2011/OrganizationData.svc/"
        + "new_datacentreSet"
        + "?$filter="
        + "new_name eq '" + accountid + "'"
        + "&$select=new_Website,Content";
 alert(oDataURI);

//var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
//var completeUrl=ODataPath+"/new_datacentreSet(guid'" +accountid+ "')";
var userRequest = new XMLHttpRequest();
//alert(completeUrl);
userRequest.open("GET", oDataURI, false);
//userRequest.open("GET", completeUrl, true);
alert("sds");
userRequest.setRequestHeader("Accept", "application/json");
alert("sds1");
userRequest.setRequestHeader("Content-Type", "application/json; charset=utf-8");
userRequest.send();
alert("sds4");
if (userRequest.status === 200)
{
alert("sdsds");
var retrievedUser = JSON.parse(userRequest.responseText).d;
alert("sdsdfdfs");
var userFullName = retrievedUser.new_Website;
alert(userFullName);
}
else
{
alert("sorry");
return "error";
}
}


Viewing all articles
Browse latest Browse all 8223

Trending Articles



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