Closed ramsabarish closed 9 years ago
You are actually redefining the ajax method in that code, not calling it. Your code can be much simpler - something like
var reportId = '00OD0000001ZbP7MAK'; // This is the ID from your code
client.ajax("/v29.0/analytics/reports/"+reportId+"/instances", function(response){
// You would do something with the response; I just alert it here
console.log('Response', response);
alert(JSON.stringify(response));
}, function(jqXHR, textStatus, errorThrown){
// uh-oh
alert("Error: "+jqXHR.status+" "+jqXHR.statusText);
});
Thanks a lot, It worked ......
Hi.. I have another problem while requesting REST API. I'm able to call synchronous run report request but I'm unable to call asynchronous run report request.
Kindly tell me my mistake.
Here I'm requesting for an asynchronous report run. It shows empty array in response and no error was shown.
forceClient.ajax("/v29.0/analytics/reports/00O28000000fSqzEAE/instances",function(response){
// You would do something with the response; I just alert it here
console.log('Response', response);
alert("Report Results :"+JSON.stringify(response));
}, function(jqXHR, textStatus, errorThrown){
// uh-oh
alert("Error: "+jqXHR.status+" "+jqXHR.statusText + JSON.stringify(jqXHR) );
});
According to the Analytics API docs, you POST to that URL to start the asynchronous report run. This gives you the instance ID that you can later use to get the results. Something like...
var requestPayload = {
name : 'ReportName',
id : '00O28000000fSqzEAE',
"currency": null,
...
};
var instanceId;
forceClient.ajax("/v29.0/analytics/reports/00O28000000fSqzEAE/instances",function(response){
// Response contains instance handle that stores the results of the run
console.log('Response', response);
instanceId = response.id;
}, function(jqXHR, textStatus, errorThrown){
// uh-oh
alert("Error: "+jqXHR.status+" "+jqXHR.statusText + JSON.stringify(jqXHR) );
}, 'POST', requestPayload);
Then, some time later, get the report instance data
forceClient.ajax("/v29.0/analytics/reports/00O28000000fSqzEAE/instances/"+instanceId,function(response){
// You would do something with the response; I just alert it here
console.log('Response', response);
alert("Report Results :"+JSON.stringify(response));
}, function(jqXHR, textStatus, errorThrown){
// uh-oh
alert("Error: "+jqXHR.status+" "+jqXHR.statusText + JSON.stringify(jqXHR) );
});
I have created a hybrid salesforce app through forceios and I'm able to show all contacts.
But now I want show the Reports so I used REST API, but the method
forcetk.Client.prototype.ajax
is not getting called and there was no error shown in xcode or browser.
I have shared the code with you, Kindly help me out...
function callback(result){
}
function getReports(){
} //End of getReports