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
CarledrissCarledriss 

Metadata API, Delete custom fields

Hi,

 

I am using Metada API to delete custom fields.

I can delete custom field of an Object, but the custom field is put in the 'Deleted Fields' with the following API name customfield_del__c

Is it possible to erase the custom field of the 'Deleted Fields' list? I need to delete them of that list as well

 

I am using the following code

 

    public static void deleteCustomField(String fullname) throws Exception 
    {
        CustomField customField = new CustomField();
        customField.setFullName(fullname);
        UpdateMetadata updateMetadata = new UpdateMetadata();
        updateMetadata.setMetadata(customField);
        updateMetadata.setCurrentName(fullname);
        
        AsyncResult[] asyncResults  = metadataConnection.delete(new Metadata[] {customField});
 
        long waitTimeMilliSecs = ONE_SECOND;
 
        do 
        {
            printAsyncResultStatus(asyncResults);
            waitTimeMilliSecs *= 2;
            Thread.sleep(waitTimeMilliSecs);
            asyncResults = metadataConnection.checkStatus(new String[]{asyncResults[0].getId()});
        } while (!asyncResults[0].isDone());
 
        printAsyncResultStatus(asyncResults);
    }
Sanchit DuaSanchit Dua

I'm also looking to erase the fields from deleted list.