Last year the company I am working for changed a number of its processes which resulted in quite a few Salesforce changes. This included amending multiple picklist fields. Some of these picklists have the same or similar values across different objects (for example Lead Source on Leads and Contacts).

Changing picklist values sounds like a simple task. However, did you know that when you edit a name of a picklist value it may disappear from report filters?

If this picklist value is used in a high number of important reports (for example a Stage value is often used on hundreds of opportunity reports), the effect of the change will be significant.

Force.com IDE allows you to mass update picklist values that are used in report filters, providing these reports are stored in public folders.

Preparation Steps

Create a Force.com IDE project and include a reports component. Don’t include any other metadata components.

Expand the folders of the project and double-click package.xml to open it. This file lists all reports included into your project.

1

Unless you are confident that users are not making any changes in Salesforce while you are updating reports and to avoid making errors the best practice is to separate reports that match your criteria into a new project.

Separate Reports into a New Project

Create a new project and include just one report into it. Metadata Components screen allows you to select all reports, individual report folders or individual reports. By selecting just one report you will minimize time required to load your metadata from server.

2

Now you have one project with all reports and another project with just one report. You want to copy all affected reports from the first project and replace that single report you added into the second project with them.

3

Copying reports into a new project can be split into three actions:

* Identify effected reports

* Change reports metadata format in Excel

* Add reports into the second project

Identify Affected Reports

Use Search functionality available in the menu for find reports that match your criteria. Your reports will most likely be shown in a Tree View on the Search tab.

4

You need to change the Search tab view to List View. This is to allow easily selecting and copying affected reports.

5

Once your search results are shown in a List View, highlight them, right-click and click Copy.

Paste copied into Excel.

6

Change reports metadata format in Excel

Use Text to Columns function to separate report names from the rest. A report name is everything before ‘.report’.

7

In column B using replace functionality remove everything before the last slash.


8

 

Now you have Report Names in column A and the names of the folders where these reports are stored in Salesforce in column B.

Using Concatenate function change the format of each record to:

<members>Report_Folder_Unique_Name/Report_Unique_Name</members>

Ensure there are no spaces in the file.

Add reports into the second project

Copy the records and replace all lines between <members> and </members> tags in the package.xml file.

9

Your result will look similar to the above. Click Ctrl + S to save.

In Package Explorer click your project to expand it. Even though you updated package.xml file, you still don’t see affected reports there. This is because you need to tell Force.com IDE to upload those reports from Salesforce.

Identify a physical location of your project: right-click on the project name, select Properties -> Resource. Check Location field. This field tells you where a copy of your metadata is stored on your PC. Open that folder -> click a project name ->src -> reports -> empty reports folder.

Go back to Force.com IDE -> click a project name and click F5. You have just removed all old data from your project.

Right-click a project name -> choose Force.com -> Refresh from Server

You have successfully separated affected reports into a new project.

Replace Picklist Values

Click Search in the menu.

Tick a checkbox Regular Expression.

Amend the below formula with the name of your picklist and its value that you want to replace, paste a formula into Notepad to remove formatting, then copy and paste it into ‘Containing Text’ field in Force.com IDE.

(<column>Account\.NASATargetAccount__c</column>\R <operator>.*</operator>\R <value>.*)Top-20(.*</value>)

Account is the name of your object.

TargetAccount__c is a name of your picklist field.

Top-20 is a name of a picklist value you want to replace with a new one.

Click Replace button.

Add the following formula into ‘With’ field

\1Strategic\2

Strategic is a new name of your picklist value.

Click Preview to see the result and then click OK.

Spot check a few report .xml files and click CTRL +S once happy.

Save the changes to server.

Important! If your org has over 10,000 reports, you won’t be able to automatically load all of them and in this case you will see an error message informing you about this problem. If this happens, you can either delete old unused reports from your Salesforce org (you can do it based on the Last Run date) or create two projects and include some of your report folders into the first project and the rest into the second one. Even though your reports metadata will be stored in different projects, you will be able to change it at the same time without having to do separate amendments for each project.

 

Share Button

Comments

comments