2

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

3
  • Could you add a screenshot with the report details (its name and API name)? It seems that you are using wrong api name of the report. Lightning report usually append some random string to api names upon first save. Commented May 29, 2019 at 7:54
  • @Eduard yes you were right. I got the API name incorrect. To view the API name I had to select the particular report and click the rename button after which I was able to see the API name in the pop-up window. I didn't find any other way to view the API name. Do know know of a way to get the api name of all the reports at once? Commented May 29, 2019 at 8:48
  • I just updated my answer to cover your question Commented May 29, 2019 at 9:24

4 Answers 4

6

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.

0
1

You can retrieve Public Reports using sf CLI like this:

(In the path, use the appropriate slash for your platform)

>sf project retrieve start -m "Report:Public Reports\My_Public_Report_API_Name" 

This retrieves it into the folder

force-app\main\default\reports\unfiled$public\ 

You can reference it in package.xml for retrieval/deployment like this:

<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>unfiled$public/My_Public_Report_API_Name</members> <name>Report</name> </types> <version>58.0</version> </Package> 
2
  • 1
    For some reason I needed to replace "\" with "/" in the following CLI command: sf project retrieve start -m "Report:Public Reports\My_Public_Report_API_Name" Commented Apr 5, 2024 at 3:26
  • I use Windows @parkerbrown. I think on non-Windows platforms the slash is the other way. Commented Apr 9, 2024 at 7:46
0

I had same issue. I ended up querying in Workbench, Writing a formula on excel to concatenate each of those by combining folder name and report name as sfdx command.

0

To do this via SF CLI v2:

  1. Create a project (if you don't have one already): sf project generate --name my-reports and go to the project directory: cd my-reports

  2. Retrieve all metadata from the org

sf project generate manifest --output-dir manifest --name=allMetadata --from-org ...

  1. Extract the list of Reports via your favorite XML manipulation tool
xmlstarlet ed -N sf="http://soap.sforce.com/2006/04/metadata" -d "//sf:types[sf:name!='Report']" manifest/allMetadata.xml > manifest/reportsOnly.xml 

produces

<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>...</members> <members>...</members> ... <name>Report</name> </types> <version>62.0</version> </Package> 
  1. Retrieve metadata for all Reports
sf project retrieve start --manifest manifest/reportsOnly.xml --target-org ... 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.