top of page

Salesforce Hacks # 2 : mass edit filters in Salesforce reports

caleksiev

Updated: Sep 22, 2023

Spoiler Alert: you need VS Code for this one


Just recently I had to deal with the following task. We have 200+ reports in an org. I needed to change the reference from all those reports to some fields. Imagine that in your reports you reference Lead.My_Custom_Field__c ( yes, I know, original... ) and you have that reference in let's say 100 of your reports. Now, you want to change all those references to Lead.My_New_Custom_Field__c for some reason ( somebody added that new field and you want to replace it with the old one ).... How do you do that? Ok, go to Reports, start opening every report one at a time and start adding the new filter field, remove the old one ..... naaaaahhhh just kidding :D Open your VS Code ( uh, told ya! ), add this extension if you don't already have it: https://marketplace.visualstudio.com/items?itemName=VignaeshRamA.sfdx-package-xml-generator

Create a new project with manifest Ctrl + Shift + P:


Authorize your org Ctrl + Shift + P:


Now, the magic begins, hit Ctrl + Shift + P ( surprise!!! ) in order to open the command pallet:

Choose Metadata Components

Type in Reports:

Mark all the reports that you want to change. You can also use the folder name as filter


After you are done, click Update Package.xml


If not opened automatically, go to manifest folder on the left, package.xml

And you will see all of your report names added to the package.xml While on the screen of the package.xml, mouse right click and retrieve source from org

You should be able to see all your reports metadata retrieved under force-app\main\default -> reports folder


Next step, click Ctrl + Shift + H for global search and replace

All the references for the field being searched will pop up and you can replace them easily with your new reference. Keep in mind that the new field should be created in Salesforce otherwise you will get an error when deploying. On the results that pop up, you can see the small button on the line with the result, if you click it, you will have your change deployed.

*On this picture I am just showing what you can do and what can go wrong. In real life the search should be "Lead.My_Custom_Field__c" and the replace should be "Lead.My_Custom_Field_New__c".


Also, if you click in the line itself, you are presented with a nice spliced by two screen, for you to view the changes. Check how using just "Lead" as a search, can break the metadata, so be careful.

I personally prefer to deploy them manually because sometimes you can update something that you don't want, or at least check the occurrences. ( Check my examples above again! ).


Imagine you are looking for My_Custom_Field__c, but you have also a Old_My_Custom_Field__c. If you don't get that one and you change them all automatically to My_New_Custom_Field__c, you will end up with

Old_My_New_Custom_Field__c

You see the difference? You will probably not be able to deploy it because you are missing a field like that, but still, errors can be produced, so be advised and be careful.

Have fun! :)

134 views0 comments

Recent Posts

See All

Comments


Proudly created with Wix.com

bottom of page