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

using oData trying to retrieve & display different fields based on lookup fields selection but getting error

$
0
0

Hi All,

I am using below js function using oData to retrive & populate relevant custom fields of an entity but it's not working and getting error that web page can not be displayed. It seems everything is good here but still not working and i can see xml page with entity and attributes with my guid.
Can someone pls look into it. Thanks for help!


function RetrieveFieldsDetail()
{

//Get the Selected field name
if(Xrm.Page.getAttribute("new_field_list").getValue() != null)
{
var id = Xrm.Page.getAttribute("new_field_list").getValue()[0].id;
var ServerUrl = Xrm.Page.context.getServerUrl();

var _oPath = ServerUrl + "/XRMServices/2011/OrganizationData.svc";
var _retrieve = new XMLHttpRequest();

_retrieve.open("GET", _oPath + "/new_field_listset(guid'" + id + "')", true);
_retrieve.setRequestHeader("Accept", "application/json");
_retrieve.setRequestHeader("Content-Type", "application/json; charset=utf-8");
_retrieve.onreadystatechange = function () { RetrieveFieldlistRequestCallback(this); };

_retrieve.send();
}
}

function RetrieveFieldlistRequestCallback(_retrieve)
{

if(_retrieve.readyState == 4)
{
if(_retrieve.status == 200)
{
var _fieldlist = JSON.parse(_retrieve.responseText);

if(_fieldlist.new_field_name != null)
{
Xrm.Page.getAttribute("new_field_name").setValue(_fieldlist.new_field_name);
}

if(_fieldlist.new_display_name != null)
{
Xrm.Page.getAttribute("new_display_name").setValue(_fieldlist.new_display_name);
}

}
else
{
window.alert("There was an error retrieving field list Information");
}
}
}


Viewing all articles
Browse latest Browse all 79901

Trending Articles