+ 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.