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
Aanchal Adhikari 10Aanchal Adhikari 10 

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 a part of the content in 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
Even if this works I'll only be able to retrieve one particular report meta-data 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
Abhishek BansalAbhishek Bansal
Hi Aanchal,

We have a limitation with the reports that we need to specify the name of each and every report in order to retrieve it. In this case, you are getting error because Public Reports folder is referenced as unfiled$public so please use this name to retrieve the report.
<members>unfiled$public/AvailableToWorkToday</members>.

The another way to retrieve all the reports related to a Folder is to use bulk retrieve approach. In this approach you have to declare multiple targets in your build.properties file and in those targets you need to specify the folder names. This will retrieve all the reports related to the folders specified in the targets.  Please let me know if you need detailed information on this.

Thanks,
Abhishek Bansal.
Aanchal Adhikari 10Aanchal Adhikari 10

Hi Abhishek,

I'd placed the wrong API name. This worked as well: 

<members>PublicReports/Available_To_Work_Today</members>

Regarding the bulk retrieve approach, are we supposed to create a new file called build.properties inside the SFDX project? Could you provide more information on how to implement this approach? I'm currently using SFDX in VS code.

Thank you,
Aanchal

Abhishek BansalAbhishek Bansal
Hi Aanchal,

I am talking about the Ant tool in which we use build.properties file to specify the  targets. Not sure about the SFDX.

Thanks,
Abhishek Bansal.