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
atulit27atulit27 

How to edit Reports and Dashboards Programmatically?

 

Hi,

 

I want to customize the Reports and Dashboards through apex code. The API's for Dashboard and Reports are not supporting this. I tried it out with this API link for Dashboards

http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_dashboard.htm

 

Is there anyway round where I can get the Reports attributes used in a Dashboard and then able to customize reports accordingly through apex code?

 

Thanks,

Atulit

atulit27atulit27
I have access to dashboard object. From this object, I am trying to reach the reports included in the dashboard. The dashboard object has three fields
leftSection
middleSection
rightSection
These are of type DashboardComponentSection.

I was hoping to get to the DashboardComponentSection from Dashboard, and then use the components field to get a list of elements of type Dashboard.
From the DashboardComponent we can get to the name of the report,

However the issue I am running into is that Salesforce does not recognize the field leftSection, middleSection and rightSection in the dashboard object. There appears to be no way to get to DashboardComponentSection from the Dashboard object.
The code below gives compilation error - 

Dashboard d =[Select Id,title,description ,LeftSection,middleSection,rightSection from Dashboard];



sfdcfoxsfdcfox

You can't SOQL this sort of data; it's covered under the Apex Metadata API. You would have to use a method that can leverage the Metadata API. You can't do this in pure Apex Code due to timing considerations (it's asynchronous), but you could use Visualforce to poll the results, then handle most of the processing in JavaScript or action functions.