[SalesForce] Using SFDX to retrieve the report meta data

I need to check if a field is being used in any of the reports in the org. So I created a sandbox environment and created a manifest project in VScode; then authorized the sandbox org and ran the command "SFDX: Retrieve Source in Manifest from Org" by right clicking the package.xml file. All the apex classes and triggers were retrieved but the reports meta data were not retrieved. Here's the content of the package.xml file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>*</members>
        <name>ApexClass</name>
    </types>
    <types>
        <members>*</members>
        <name>ApexComponent</name>
    </types>
    <types>
        <members>*</members>
        <name>ApexPage</name>
    </types>
    <types>
        <members>*</members>
        <name>ApexTestSuite</name>
    </types>
    <types>
        <members>*</members>
        <name>ApexTrigger</name>
    </types>
    <types>
        <members>*</members>
        <name>AuraDefinitionBundle</name>
    </types>
    <types>
        <members>*</members>
        <name>LightningComponentBundle</name>
    </types>
    <types>
        <members>*</members>
        <name>StaticResource</name>
    </types>
    <types>
        <members>PublicReports/AvailableToWorkToday</members>
        <name>Report</name>
    </types>
    <version>45.0</version>
</Package>

But I get the error: Entity of type 'Report' named 'PublicReports/AvailableToWorkToday' cannot be found

The name of the report folder is 'Public Reports' and the name of the report is 'Available To Work Today'.

Even if this works I'll only be able to retrieve the meta-data of one particular report which is of no help as I need to retrieve all the reports meta-data at once.

Any help on this would be great. Thanks

Best Answer

It seems that you are using a wrong api name of the report. Lightning reports usually append some random string to api names upon first save. So make sure you provide the correct names in the manifest.

Even if this works I'll only be able to retrieve the meta-data of one particular report which is of no help as I need to retrieve all the reports meta-data at once.

As per docs - Report:

You can’t use the wildcard (*) symbol with reports in package.xml.

This means you have to list all the report you want to retrieve in your manifest. Once you do that you will be able to retrieve all the reports meta-data at once.

Do know know of a way to get the api name of all the reports at once?

Since the Report.obj is supported for queries, you can get api names of all reports just by running a simple SOQL query. While in the developer console, execute the following command in the Query Editor:

SELECT Id, Name, FolderName, DeveloperName FROM Report 

This will list all reports and their api names (DeveloperName) in your org.

Related Topic