Answered by:
Odata query results

Question
-
Hi,I am trying to retrieve data from another entity using Odata query.
I do see the results in 'd' when I debug, but data is not loading into 'retrieved' variable and
I am seeing undefined in the alert box.What am I doing wrong?
function priority()
{
debugger;var serverUrl=Xrm.Page.context.getClientUrl();
var oDataSelect=serverUrl+"/XRMServices/2011/OrganizationData.svc/new_tasksintSet?$select=new_task_new_tasksint_Task_TasksInt/new_TaskIssuePhase&$expand=new_task_new_tasksint_Task_TasksInt";var retrieveReq=new XMLHttpRequest();
retrieveReq.open("GET", oDataSelect, false);
retrieveReq.setRequestHeader("Accept", "application/json");
retrieveReq.setRequestHeader("Content-Type", "application/json;charset=utf-8");
retrieveReq.onreadystatechange = function () {
GetTaskIPData(this);
};
retrieveReq.send();
}function GetTaskIPData(retrieveReq) {
if (retrieveReq.readyState == 4) {
if (retrieveReq.status == 200) {
var retrieved = JSON.parse(retrieveReq.responseText).d;
if(retrieved.results[0].new_TaskIssuePhase!=null){
alert(retrieved.results[0].new_TaskIssuePhase.Name);
}
}
}
}Thanks for any help!
Monday, September 22, 2014 8:34 PM
Answers
-
JavaScript is case sensitive.
please try new_TaskIssuePhase.name?. You could also addwatchon the variable new_TaskIssuePhaseand seetheresults to find the right case.- Marked as answer by roxannaappleby Tuesday, September 23, 2014 7:32 PM
Monday, September 22, 2014 8:46 PM -
Hi,
use ODataQuery designer tool and run the query. It will show you the xml it returns.
Then check for the record count and new_TaskIssuePhase is existed or not. If yes check for name under the node.
For more info follow this. http://crmscape.blogspot.in/2011/03/crm-2011-odata-json-and-crm-forms.html
Thanks,
Sreeni Pavalla
- Marked as answer by roxannaappleby Tuesday, September 23, 2014 7:32 PM
Tuesday, September 23, 2014 12:30 PM
All replies
-
JavaScript is case sensitive.
please try new_TaskIssuePhase.name?. You could also addwatchon the variable new_TaskIssuePhaseand seetheresults to find the right case.- Marked as answer by roxannaappleby Tuesday, September 23, 2014 7:32 PM
Monday, September 22, 2014 8:46 PM -
Thanks for noticing it.
But the problem still exists. It actually not loading data into 'retrieved' variable.
I am not able to see 'retrieved' in the 'Locals'. What could be the reason?
Monday, September 22, 2014 9:06 PM -
put the break point inside the function. Or declare the variable outside the function to change the scope.
regards,
Jithesh
Monday, September 22, 2014 9:16 PM -
Hi,
use ODataQuery designer tool and run the query. It will show you the xml it returns.
Then check for the record count and new_TaskIssuePhase is existed or not. If yes check for name under the node.
For more info follow this. http://crmscape.blogspot.in/2011/03/crm-2011-odata-json-and-crm-forms.html
Thanks,
Sreeni Pavalla
- Marked as answer by roxannaappleby Tuesday, September 23, 2014 7:32 PM
Tuesday, September 23, 2014 12:30 PM -
Download query designer and run the Odata comand in your environment and test the results:-
http://crm2011odatatool.codeplex.com/
Regards Faisal
Tuesday, September 23, 2014 3:02 PM