Pages

Sunday, September 4, 2016

Salesforce: Delete Custom Field

As Salesforce admin you may aware that it is very easy to create a custom field in Salesforce, the same also to delete a custom field. But, Salesforce is smart enough to detect if a field you try to delete is used in some business rules, such as: validation rules, workflow rules and etc., and it will stop you to delete the field.


In this blog, I would like to share items that will stop you from deleting a custom field when it is used in:

1. Validation Rule
If the rule is Active - deletion NOT ALLOWED
If the rule is Inactive - deletion ALLOWED, field name is not changed, but cannot be save if you edit the validation rule without change anything, error message "Field field_name__c not exist"

2. Custom Formula Field
NOT ALLOWED

3. Workflow Rule (include Approval Process)
  * as dropdown / criteria are met - Active or Inactive - NOT ALLOWED
  * as formula evaluates to true - Active or Inactive - NOT ALLOWED

4. Field Update action for Workflow Rule
NOT ALLOWED

5. Email Template
ALLOWED - sample: {!Account.field_name__c} will become {!Account.00N50000002yCez}. Undelete the field will change the API field name with _del__c, and it is updated in Email Template.

6. Apex Trigger
Active or Inactive - NOT ALLOWED

7. Apex Class
NOT ALLOWED

8. Process Builder (as condition / dropdown)
  * use as Criteria - NOT ALLOWED
  * use as Filter in Record update - NOT ALLOWED
  * use as Field Values in Record update - NOT ALLOWED

9. Process Builder (as formula)
  * use as criteria - NOT ALLOWED

10. Flow
Active or Inactive - NOT ALLOWED

This blog is written in Summer '16 release, so things may change in the future, please comment if you found something changed, or any rules not covered above.

In short, it is pretty safe to delete unused fields and Salesforce will detect for you prior deletion, with exception in: inactive validation rules and email template, and also in: report, dashboard, and page layout.


Additional tips: when you delete email template, Salesforce will stop you when the email template is used in Email Alert.