Retrieve Reports using package.xml

To know more about Private Reports: ClickHere

We can't directly add just the Report name to retrieve from org. We need to specify the folder details based on the above categories. If we are targetting to extract multiple reports then to get the Folder Names, use the below 2 queries.

SELECT id,name,developername,foldername FROM Report

SELECT id,name,developername FROM Folder 

Examples of package.xml file 
To retrieve Report details from Public folder:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>unfiled$public//ReportAPIName</members>
<name>Report</name>
</types>
<version>46.0</version>
</Package>

To retrieve Report details from custom folder:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>FolderAPIName</members>
<members>FolderAPIName/ReportAPIName</members>
<name>Report</name>
</types>
<version>46.0</version>
</Package>

Other solution:
1. Create an Outbound changeset( assume, your changeSet name is: "All Reports to Extract"). 
2. Add all the Reports that you're planning to extract and also include the folders. Below is the screenshot for reference
3. Now, from workbench just pass the outbound Changeset name as shown in the below screenshot
Now with either of the above solutions, you will get the Reports&Folder information into a zip file. Now if you want to convert this into source format, then extract this zip file, keep that extracted files into a folder and convert it into Source format using the below SFDX command.
sfdx force:mdapi:convert --rootdir \MISB\Reports

Note: In the above command, "\MISB\Reports" folder contains the extracted files of the zip file.

Use case:
I wanted to check with whom(Role, Group, or individual user) the report is shared.

with the above package.xml file, we can see the retrieved file like below (Use VS code for searching, clickHere): 
<?xml version="1.0" encoding="UTF-8"?>
<ReportFolder xmlns="http://soap.sforce.com/2006/04/metadata">
    <folderShares>
        <accessLevel>View</accessLevel>
        <sharedTo>CIO</sharedTo>
        <sharedToType>Role</sharedToType>
    </folderShares>
    <folderShares>
        <accessLevel>View</accessLevel>
        <sharedTo>SLTMembers</sharedTo>
        <sharedToType>Group</sharedToType>
    </folderShares>
</ReportFolder>

Comments