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
Bharath Kumar ThotaBharath Kumar Thota 

Retrieve "Report" records based on Object type

Hi,
I want to retrieve records of "Report" based on "Object". Is this possible?
In one picklist I have Objects when I select a particular object for example let us take it as Opportunity, so in the next picklist I need to get the report records which are related to Opportunity object.
Retrieving the report records based on object is possible?

Thanks,
Bharath Kumar Thota
Best Answer chosen by Bharath Kumar Thota
Abhishek BansalAbhishek Bansal
Hi Bharath,

You can use the link given by Maharajan to display the records of different obejcts in the same VF page.

For your query to get the Report object: Unfortunately you can't use SOQL to query for report data. If you must get report data, you can use the reports and dashboards REST API.
https://developer.salesforce.com/docs/atlas.en-us.api_analytics.meta/api_analytics/sforce_analytics_rest_api_intro.htm

Thanks,
Abhishek Bansal.

All Answers

Abhishek BansalAbhishek Bansal
Hi Bharath,

When you create a Report, the first step is to choose the Report Type where you identify the object on which you to build the Report and once Report Type is chosen there is no way to choose it.
However there is a way to achieve what you want. Create sample reports on all of the objects that you want to display in the drop-down and based on the selection of Object just called the respective Report matching the object name.
The second option would be to use a SOQL on the object selected in the drop down and display the records on VF page but that will not have several features provided by Reports so I think you can go with the first option.

Let me know if you need any more help or information on this.

Thanks,
Abhishek Bansal.
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790
Phone: +917357512102
Bharath Kumar ThotaBharath Kumar Thota
Hi Abhishek Bansal,
Thank you so much for the reply. Actually I was bit confused with the answer. If we go according to the first option, we may or may not have the record names based on object name so we can a get a problem there.
Once again I will explain with an so that if you didn't understood my above requirement so this can be useful. In first picklist I have several object names from that if I select any Contact so I need to get all the records of Contact in second picklist. In the same way for the "Report" records also I need to get the records based on Object. According to you what I understood is, it is not possible to retrieve the overall information of Report records based on object using SOQL query.
Please can you reply for this and help me so that it will be useful for me.

Thanks,
Bharath Kumar Thota
Maharajan CMaharajan C
Hi Sharath,

I think you are expecting the same functionality as mentioned in below link. So please confirm this what you are expecting?

If you have already builded the logic for display the object names object then just refer the records fetch logic from below link.

https://sfdcfacts.com/apex/dynamic-record-display-how-to-display-record-of-any-sobject-on-same-visualforce-page/

Thanks,
Maharajan.C
 
Abhishek BansalAbhishek Bansal
Hi Bharath,

You can use the link given by Maharajan to display the records of different obejcts in the same VF page.

For your query to get the Report object: Unfortunately you can't use SOQL to query for report data. If you must get report data, you can use the reports and dashboards REST API.
https://developer.salesforce.com/docs/atlas.en-us.api_analytics.meta/api_analytics/sforce_analytics_rest_api_intro.htm

Thanks,
Abhishek Bansal.
This was selected as the best answer