function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
College ManagementCollege Management 

Can i get report data which is visible to only a particular user via salesforce analytics?

I've gone through Salesforce Analytics Rest Api ( implemented an apex class which will make rest call
services/data/v32.0/analytics/reports/<reportId>?includeDetails=true and get report data of a given report id, It is retrieving all the records containing in the report but my requirement is to retrieve the report data which is visible to a particular user.
Please help me out.

Thanks !
ShashankShashank (Salesforce Developers) 
"Running User" can be set only for dashboards. Reports cannot be run as a particular running user even through the UI, unless we login as the user.

Even in the analytics API, we should login as the particular user to get data that he has access to.
College ManagementCollege Management
Yes even i've done research on it but didn't find any way to achieve it. Isn't there any workaround to acheive it ? I am using rest call to login by hard coding username and password of a particular user. As we cannot query password of users we can't login as an user.
College ManagementCollege Management
I've gone through Outbound Message, i am bit confused with it. As you said if i want to generate an excel report as a particular user then i can specify the user in " USER TO SEND AS " field, but what if i want to generate an excel as different users. My requirement is exactly same as " Running User " (Report Tab --> select any report --> Run Report drop down -->Schedule Future Runs --> Running User ) while scheduling report. I created an object with fields Running User (User Lookup), ReportId and Email field . And i am running a batch to retrieve records and send report as an attachment to an email address of a corresponding record. So based upon the selected running user i should generate an excel from report and send an email as an attachment. 

Thanks ! 
Prachi Gadewar SFDCPrachi Gadewar SFDC
@College Management
Can you please post your code which will make rest call
services/data/v32.0/analytics/reports/<reportId>?includeDetails=true from apex. I did but got Readtime out exception. I am looking for kind of help. Help would be appriciated.
College ManagementCollege Management


There you go, get the token  and place it to header.

String addr = 'https://<your instance>/services/data/v32.0/analytics/reports/<reportId>?includedetails=true';
HttpRequest req = new HttpRequest();
req.setEndpoint( addr );
req.setHeader('Authorization', 'Bearer ' + token);
Http http = new Http();
HttpResponse response = http.send(req);

Thanks ! :)