Pages

Sunday, September 4, 2016

Salesforce: Delete Custom Field

As a Salesforce admin, you may be aware that it is straightforward to create a custom field in Salesforce, and the same also to delete a custom field. But, Salesforce is smart enough to detect if the field that you try to delete is used in some rules, such as validation rules, workflow rules, apex class, etc., and the system will stop you from deleting 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 - NOT ALLOWED
If the rule is Inactive - ALLOWED, if you edit the validation rule without removing the deleted field, you cannot save the validation rule and will get an 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

11. Report
ALLOWED - both in filter and report will be removed

12. List View
ALLOWED both in filter and view will be removed

13. Page Layout
ALLOWED

14. Dynamic form
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 it for you before deletion, except inactive validation rules and email templates, and also in report, dashboard, and page layout.


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



2 comments:

  1. Summary:
    Field deletion directly happens from email template, report, dashboard, and page layout. Deletion is prevented due to use in active validation rules, custom field formula, workflow rules, Apex trigger, Apex class, Process builder or Flow. If deletion happens, associated data gets deleted.

    ReplyDelete