How To Bulk Delete Inactive Picklist Values?



In this post, we will be sharing the step-by-step process of bulk deleting the inactive picklist values from salesforce org. Actually before the summer ’22 release, it was quite a tedious task to perform the deletion of inactive values of custom picklists. The reason behind this was that you can only delete one at a time. However, with the salesforce summer’22 release, we got the flexibility to bulk delete unused inactive picklist values

Let’s begin and have a glance at the requirement and its implementation.

Requirement Overview

  • Delete all the unused values of custom picklist in one go with impact analysis and taking care of historic data in the org.

Solution Approach

Impact analysis of the inactive values that might have been used anywhere in the code or hardcoded in the repository.

Update the existing data residing in the org with specific value discussing with your business or data team before deleting the picklist value from the environment.

Delete all the unused picklist values of custom picklists in one go.

Demo

Let’s say you have any custom picklist field on opportunity having inactive values in it.

Picklist field – Lead_Region__c
Inactive values – New York, Americas

Your initial task would be to analyze if field Lead_Region__c having values New York or Americas are present in the code or any automation logic. The reason for this is sometimes we inactive the values but instances in the code remain due to hardcoded values that were placed during the development. Remove all the instances from the repository. You can leverage Visual Studio code in performing this action.

The next step is to query the object

Select id, Lead_Region__c from opportunity where Lead_Region__c In (‘New York’,’Americas’);

Update the Lead_Region__c field returned from above query by specific value after discussion with your business as it can impact your production data if not done with due diligence.

Once you are good with the data update, you can proceed for the manual step mentioned below.

  • Click Setup.
  • Click on Object Manager, and select your Object.
  • Click on Fields & Relationships, and click the picklist field. In the Picklist Values Used section, you can see how many inactive picklist values the field has.
  • From the Inactive Values section of the picklist field, click Delete Unused Values.

After all of the picklist values have been deleted, you will receive an email indicating whether or not the deletion was successful. The email is sent to the user whose email address was used to initiate the deletion.

Note – If data exists in your org with inactive values then unused values would not be deleted even if you click the button Delete Unused Values. Please find the below image for reference.

Conclusion

You should be cautious when deleting inactive picklist values, as this could impact existing data and reports. I would suggest to have proper impact analysis and then approach to this requirement.

How To Bulk Delete Inactive Picklist Values?
I Hope you find this post useful! Catch you in the next content.
And thank you for being an awesome reader.
Share and grow together !!

If you have any doubts you can comment down below, I will try to reply ASAP.

Also keep visiting us, for more such content!

Adil Ansari

Md.Adil is a Senior Salesforce developer, a Computer Science graduate working on the Salesforce platform and providing customer solutions using force.com as a Salesforce consultant/developer. He is the founder of SalesforceBitsandBytes blogging site. He shares unique real time posts on different Salesforce implementations, the source code available on this SalesforceBitsandBytes blog is fully tested in the development environment.

Leave a Reply

Your email address will not be published. Required fields are marked *