How to deploy or retrieve dashboard folder?

Today I have been struggling trying to migrate reports and dashboards from developer organization to production. Looks like we can’t deploy dashboard without a folder. While for reports there exist standard ‘Unfilled Public’ folder, for Dashboard there is no predefined public folder.
When I tried to deploy the dashboard I kept receiving error

Public_Dashboards/Jobs_Executed_and_Booked_For_This_Week Dashboard 0 0 Cannot
find folder:Public_Dashboards

even when I tried to add folder to package.xml like this

<types>
    <members>Public_Dashboards</members>
    <name>Folder</name>
</types>

I still kept receiving the same error with additional messages like

Public_Dashboards/Jobs_Executed_and_Booked_For_This_Week Dashboard 0 0 Cannot
find folder:Public_Dashboards 0 0 Unknown type name ‘Folder’ specified
in package.xml

When I tried to specify DashboardFolder type in package.xml

<types>
    <members>Public_Dashboards</members>
    <name>DashboardFolder</name>
</types>

I still had the same error with a different message

0 0 Unknown type name ‘DashboardFolder’ specified in package.xml
Public_Dashboards/Jobs_Executed_and_Booked_For_This_Week Dashboard 0 0 Cannot
find folder:Public_Dashboards

How to deploy or retrieve dashboard folder?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Today I have found an answer in docs here:
https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_folder.htm

First of all, to migrate dashboards and folder you have to create public dashboard, then you can retrieve or deploy in the same way.

The documentation gives example for Document folder

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>basic</fullName>
    <types>
        <members>sampleFolder</members>
        <members>sampleFolder/TestDocument.txt</members>
        <name>Document</name>
    </types>
    <version>37.0</version>
</Package>

but this works in the same way for Dashboard folder

<types>
    <members>Public_Dashboards</members>
    <members>Public_Dashboards/Jobs_Executed_and_Booked_For_This_Week</members>
    <name>Dashboard</name>
</types>

Method 2

This is because the dashboard folder is not present on the target.
When you use the following while retrieving :

<types>
    <members>Public_Dashboards</members>
    <members>Public_Dashboards/Jobs_Executed_and_Booked_For_This_WeekDashboard</members>
    <name>Dashboard</name>
 </types>

It will create a dashboard folder with the same name and folder sharing with correct access levels as on the source org.

Method 3

You can retrive the folder metadata if you use this code.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>basic</fullName>
    <types>
        <members>uniqueFolderName</members>
        <name>Report</name>
    </types>
    <version>37.0</version>
</Package>


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x