I'm working on a statndard object like Opportunity, where I have a picklist lets say Status__c on it.

Since Opportunity is a common object for multiple teams, Status field it is being used in the code base a lot.

I want to write some apex on a new Status value called "Pseudo Approved", but i'm not sure this picklist field's value will be used for a long time. (I'm expecting it to be deleted from field level itself)

I am looking for a solution where someone from other team when have to delete/replace the picklist value, should be prompted with my apex code saying its been used here.

Currently I can just declare it as a final string constant and refer that const variable so that they dont have to replace it everywhere, is there a better solution to this.

I am looking for direct refering the picklist value so that apex knows its a picklist value and not just normal string.


I tried to statically reference a picklist value, to check if that will appear when trying to delete the picklist value with no success. So there is no standard option to prompt the user when deleting a picklist value

Maybe your best option is to create a test method that detects if that picklist value exists. This will allow the other developer to update that value in a Sandbox but will appear when trying to run tests in a deployment

Then in your test method, you can specify further instructions, like where is that picklist value used, and what changes are necessary to do

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.