Is it December already?? I’ve been saying all year that I was going to do a massive org metadata cleanup… whoops. Well, I can still get quite a bit done – and better late than never!
There is a lot of emphasis on data cleanup, but metadata cleanup is just as important! Too much metadata clutter can slow down the firing of workflow rules and Apex code, cause you to hit limits, and in general just make it hard for you to create and manage configuration. Here are some of my favorite tricks to quickly clean up metadata clutter.
1. Clean up Reports that are no longer used. This is always on my cleanup list, because it is an ongoing issue! To find the Last Run date of all your reports, simply create a new report using the standard report type “Reports,” add filters to look for never-run or run more than X months/years ago, and sort by Run Date. Easy, right? Sure, if you don’t want the ID.
If you do want the ID – or the Unique Name, or who created the report – all you have to do is to create a new Custom Report Type. Just use the “Reports” object – you don’t need anything else – and save it.
Run a report using that report type – and all of a sudden, you have those additional values to pull into your report… I don’t know why, so don’t ask. Let’s just call it one of the charming quirks of Salesforce reporting.
Warning: if you also plan on deleting folders, first move the reports to a folder that you are not deleting, and then delete the reports. Otherwise, you will not be able to delete the folder that contained the deleted reports without deleting them from the Recycle Bin.
2. Clean up Dashboards that are no longer used. Finding out when a dashboard was last viewed is not as easy as it is with a report. For this, I like to use Workbench. You’ll want to log in with your Salesforce credentials, and then select SOQL Query for the Dashboard object.
In the query screen, make sure to at least pull in the Title and the LastViewedDate. I like to sort by LastViewedDate (nulls first) so I can see which dashboards were last viewed the longest ago, or never.
Click query, and you will get your list of dashboards!
A word of warning on deleting dashboards: it’s not as simple as reports. You will want to follow these steps:
- Delete the components from the dashboard. (If you do not remove the components, you will not be able to delete the related reports while the dashboard is in your Recycle Bin.)
- Save the dashboard once it is empty.
- Move the dashboard to a folder that you will not be deleting. (You cannot delete a folder while its dashboards are in your Recycle Bin.)
- Delete the dashboard.
3. Clean up Report and Dashboard Folders that are no longer used. I will repeat my warning from earlier: if you want to delete report or dashboard folders, emptying them is not enough – you can delete everything in a folder, but when you try to delete the “empty” folder, you’ll get this error:
Everything that was in those folders must no longer be in the Recycle Bin – simply deleting them is not enough. The logic behind this restriction is, if you go to your Recycle Bin and undelete a report, it will be put back into the same folder. If that folder has been deleted, then the undeleted report will have nowhere to go.
To get around this, move reports that you wish to delete to the My Personal Custom Reports folder first – because that folder will be there forever – and then delete the reports. For dashboards, move them to My Personal Dashboards before deleting. (Any other folder will do, so long as you know you do not plan to delete it.)
4. Find out if you are wasting User licenses. There are two things I look for when I want to free up some licenses:
First: Go to Setup | Manage User | Users. There should already be a standard list view called Active Users. Sort that list view by Last Login, and you’ll have something like this:
This is a great reminder that I need to deactivate ex-employees, as well as an interesting look at whether people are logging in or not (which can enable me to start conversations, if necessary, about who needs a license and who doesn’t).
Second: What if I’ve frozen some users and don’t remember which ones they are? This is not accessible in a Users report, but you can create a new list view to find out which users have been frozen. Just specify “Is Frozen = true” – and I also like to add “Active = true” because I am usually looking for active users who have been frozen.
Note: if you use the SalesforceA app, you can easily access a list of frozen users within the app!
5. Clean up Profiles with no users. This is not difficult, but it is a three-step process:
Step 1: Run a report of active users, summarize by Profile, hide details, and you will have a list of all profiles assigned to active users.
Step 2: Look at the list of your profiles in Setup | Manage Users | Profiles – how many are there?
Step 3: Go into each profile that did not show up on your report. If it contains inactive users and you do not think you will need that profile again, assign a different profile to the users, then delete the profile. Note: Salesforce will not let you delete a profile that contains any users, even inactive ones.
You can repeat this for Roles, but be careful here: unlike profiles, roles are connected to one another in the Role Hierarchy. Make sure that you are not deleting a role that is a key part of your hierarchy.
6. Clean up duplicate/similar Profiles. This seems to happen in every org I’ve ever seen! A couple of years ago, I discovered the PermComparator app, and it changed my life. Here is how it works:
Log in here with your Salesforce credentials, and click “allow” on the next screen to allow access. You then have your choice of three metadata components to compare: Users, Permission Sets, or Profiles – or any combination thereof.
Then you can drag & drop what you want to compare! In this example, I am comparing two profiles:
For cleanup of profiles or permission sets, I like to look at the “Differing Perms” section. It is broken out into User Permissions (from App Permissions, System Permissions, etc.), Object Permissions, and Setup Entity Permissions (things like apps, Visualforce pages, Apex code, etc.). Unfortunately, it does not compare field-level permissions.
Once I’ve seen all of the differences, I can combine profiles with similar (or the same) permissions into one profile, put the users from those profiles into the one I want to keep, and delete the extra one.
7. Clean up unused fields. There’s an app for that! One of the most-loved, best-reviewed apps on the AppExchange is Field Trip, which will analyze your fields and how often they are used.
Install Field Trip as you would any app. Once installed, go to the Field Trip tab and click New Field Trip.
- Give your Field Trip a name.
- Select the object which you would like analyzed.
- Save (the click the Analyze button on the new field trip), or click Save and Analyze.
Once analyzed, a related list will appear on the field trip:
You can go into the list and sort by Populated On (the exact number of records on which each field is populated) or by Populated on % (the percentage of records on which each field is populated), to see which fields are being used the least.
Field Trip can be used on all standard or custom objects in your org. It also comes with a couple of sample reports, and you can create more reports on all of your field trips for deeper analysis.
It’s a good idea to be careful when deleting fields – this is my process:
- Change the field name so I know it’s flagged for deletion. (I like to add “zzz” to the beginning of the name so that when I look at an object’s fields, those fields are down at the bottom of the list.)
- Change the field-level security so that users can no longer see the field. (Make sure to leave it this way for a while – your users will most likely alert you if they notice the missing field.)
- Set a task – I do this for 90 days out – for yourself to clean up those fields.
- Export any existing data from the fields that you intend to delete, along with the record IDs – this way if anyone freaks out, you can quickly re-create the field and replace the data.
- Delete the field(s).
8. Clean Up Page Layouts and Record Types. This is the last step in my cleanup – the main reason being, I will have less page layout assignments and record type defaults to worry about if my profiles have already been cleaned up.
There isn’t a really easy trick for this kind of cleanup – but here’s how I do it. First, I look at my page layout assignments:
Then, I look at the page layout list to find layouts that aren’t assigned to anyone:
While it’s a no-brainer to simply delete unused layouts, I like to take a look at them before deleting, to see how they are different from the current layouts, which might give me ideas for optimizing those layouts.
Cleaning up record types is less simple. I like to do it by creating a report, summarized by Record Type and Created Date. (Group the Created Date by month or year if that makes it simpler.)
In this example, I have one record type that has not been used since 2011 – this looks like a perfect candidate for cleanup! But again, let’s not be hasty. Consider the following before deleting a record type:
- Does that record type have its own page layout, and if so, how is it different?
- Do you have validation rules or workflow rules or Apex code that is looking for/updating to that record type?
- Do you have picklist values that are unique to that record type?
- Do any of your profiles have that record type as their default?
- Is there another record type that makes sense to assign to those records?
Then – again, before deleting the record type entirely – I like to simply deactivate it and let it sit for a while to make sure that it doesn’t cause issues for anyone.
I hope this info has been helpful. Happy holidays, and happy New Year cleaning!!