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
Anne LewsonAnne Lewson 

I need to delete a large set of Dashboards

Iunderstand that I will need to first  delete dashboard-components from dashboards but I don't see this object in DATALOADER when using delete.
Same questions with Report:  Is there a mehtod I could use to mass delete reports ? 
 Could you help me pls? thankyou 
Raj VakatiRaj Vakati
AS per my undserstaing, there is no mass dashboard delete option .. but you can mass delete reports 

In Setup, under Data Management | Mass Delete Records, select Mass Delete Reports and configure a filter to find reports that need to be deleted. See Deleting Multiple Records and Reports for detailed instructions.
Reports that you delete go into the recycle bin. They aren’t permanently deleted until you clear your recycle bin.


refer this link

http://releasenotes.docs.salesforce.com/en-us/summer14/release-notes/rn_analytics_mass_delete.htm
https://success.salesforce.com/ideaView?id=08730000000kq5vAAA
https://help.salesforce.com/articleView?id=dashboards_del.htm&type=0
https://success.salesforce.com/answers?id=90630000000hmATAAY
 
Alain CabonAlain Cabon
Hi,

How many dashboards? There is bug for the "mass delete reports" (> 200). Perhaps fixed now.

There is an alternative that works with curl -delete but useless if the "mass delete reports" is sufficient for you.
 
Anne LewsonAnne Lewson
@Raj Vakati above:  Thank you. I knew of that option but it requires selction critieria  not a specific file.  which still be be useful of course.  so thanks 
@Alain  Cabon,  i have over 200 dashboards to delete.  thanks in advance.  
Alain CabonAlain Cabon
@Anne Lewson:

Delete a Dashboard: Delete a dashboard by sending a DELETE request to the Dashboard Results resource. Deleted dashboards are moved to the Recycle Bin.
Example:  This DELETE request /services/data/v34.0/analytics/dashboards/01ZD00000007S89MAE to the Dashboard Results resource deletes the dashboard and returns a 204 HTTP response code with no content in the response body.
https://developer.salesforce.com/docs/atlas.en-us.api_analytics.meta/api_analytics/analytics_api_dashboard_delete.htm#sforce_analytics_rest_api_delete_dashboard

1) The curl command line is the shortest command but not easy to install.

curl —X DELETE —H "Authorization: Bearer sessionId" "https://instance.salesforce.com//services/data/v43.0/analytics/dashboards/01ZD00000007S89MAE"

2) Python is standard, easier to use for getting the session Id and the instance name:

     2.1) install python (exe) :   https://www.python.org/downloads/

     2.2) install simple-salesforce:  https://pypi.org/project/simple-salesforce/
            c:\> pip install simple-salesforce

     
2.3) create this source file: delete_dashboard.py
            
c:\>python delete_dashboard.py
import requests
import os
from simple_salesforce import Salesforce

sf = Salesforce(username='username', password='password', security_token='security_token')
sessionId = sf.session_id
instance = sf.sf_instance
print ('sessionId: ' + sessionId)

dashboardid = '01Z1v000000zEg7'

response = requests.delete('https://' + instance + '/services/data/v43.0/analytics/dashboards/' + dashboardid,
    headers = { 'Content-Type': 'application/text', 'Authorization': 'Bearer ' + sessionId })

print(response.text)
filename='result.txt'
f1 = open(filename, "wb")
f1.write(response.text)
f1.close()
print('result: '  + os.path.realpath(f1.name))
response.close()
response = requests.delete the dashboardid

When you will have installed python and simple-salesforce, we will create the loop with all the Ids of dashboards that you want to delete.
Anne LewsonAnne Lewson
@Alain Cabon: in the process of installing python ( I am pretty new at this... )  just curious:  why python?  would an apex command also allow me to do that?    thanks for the info.  
Alain CabonAlain Cabon
@Anne Lewson

Python would be useful otherwise you need to deploy the code below in production for an apex class or just use the anonymous code below and give the special authorization for the remote settings.

Rest Api in Apex: samples with ... curl
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest_code_sample_basic.htm


Equivalent in Apex anonymous window:
//Submit an HTTP DELETE request
static public String getHTTP(String svcURL) {
        //HTTP objects
        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/text');       
        String domainUrl = URL.getSalesforceBaseUrl().toExternalForm();      
        req.setEndpoint(domainUrl + svcURL);
        req.setMethod('DELETE');                
        Http h = new Http();
        HttpResponse res = h.send(req);    
        return res.getBody();
 }
static void deleteDashBoard(String dashboardId) {
    String response = getHTTP('/services/data/v43.0/analytics/dashboards/' + dashboardId);
    System.debug('response:' + response);
}

deleteDashBoard('01Z1v000000zEg7');

Warning: IMPORTANT: at the first launch, you will get a clear error message (very likely): just follow the commands given by the error message for the needed remote settings (security) and that will work at the second launch.
 
Alain CabonAlain Cabon
For the code in Python, the sandboxes also need domain='test'
 
from simple_salesforce import Salesforce
sf = Salesforce(username='myemail@example.com.sandbox', password='password', security_token='token', domain='test')

https://pypi.org/project/simple-salesforce/
 
Anne LewsonAnne Lewson
Thanks Alain, 
I am still lost. sorry.
if you feel you can spare a few minutes and take me through the steps maybe we can have a skype seesion.   let me know pls.  email > AnneLewson@gmail.com  skype handle Anne Lewson  
thanks in advance. 
Alain CabonAlain Cabon
Hello Anne,

In fact, do you want to delete "reports" ? (the dashboards components).

You just need to change /dashboards/ with /reports/
String response = getHTTP('/services/data/v43.0/analytics/reports/' + reportId);

You want to delete the reports first and then the dashboards? 

your question: "I need to delete a large set of Dashboards"  and also the underlying reports?

Your problem now is to identify the report Ids and the dashboard Ids?

You should use the workbench where you can query and export the results for the objects: Report and Dashboard.
https://workbench.developerforce.com/login.php

À bientôt
Alain
Anne LewsonAnne Lewson
hello Alain,  Merci pour l'addresse URL. C'est la premiere fois que je la vois...  est-ce que tu habite en France?  Je susis Francaise mais j'habite aux US.   
I  connected to my sandbox to first  test a single Delete of a dashboard component 
Before I jumped in and delete  a BUNCH of components  :   I used the SOQL query and selected components for a given dashboard ID   then I right cliked on one of the components and used "delete"  option   I got "  It does not seem like this record can be deleted. Are you sure you wish to continue?" 
I verified my login settings in Workbench and I am definitely logged in as me   and Iam a system admin  so I should be able to delete that records... unless SF keeps that right internally.

I also checked that the component I wanted to deleted  is not used in other dashboards and it is not   ( just that  one) ...

hmmm... ?.  what do you think? 
Merci D'avance. (encore 1 fois)
Anne