function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Permanently/Hard delete custom field from Contact entity.

I am having problem in deleting custom fields permanently.

Like for e.g.
I have created a custom field in Contact entity with name "Newsletter" which Salesforce internaly stores as "Newsletter__c" as custom field.

Then I use the below code to delete custom field of contact.

    var cstField = new CustomField
      type = FieldType.Checkbox,
      fullName = "Contact.Newsletter__c"
    // Delete the object
    var r = metaService.delete(new Metadata[] { cstField })[0];

The above code deletes the custom field, but keeps it under "DeletedFields" category where you can again "Erase" or "Undelete" the custom field. These custom fields are deleted automatically after 15 days.

I want to delete the custom fields from these category also as if I again create cf with same name SF gives error like "Already exists".

I also tried purgeOnDelete option too while deploying but no luck so far.

Please help.
Ankit AroraAnkit Arora
Yes, you are right deleted fields are kept under "DeletedFields" for 15 days. But if you want to delete it completely then click on "Erase" (field will be deleted permanently) so you can create the new field with same name.