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
Jay JanarthananJay Janarthanan 

Erasing Fields on a Custom object using Force.com IDE or API

Can this be done ?

Every time I erase a field name by taking out the whole XML that defins the field like

<fields> <fullName>Comments__c</fullName> <description>add your comments about this object here</description> <inlineHelpText>This field contains comments made about this object</inlineHelpText> <label>Comments</label> <length>32000</length> <type>LongTextArea</type> <visibleLines>30</visibleLines> </fields>

and save to the server , nothing happens and my local copy get refreshed with the orignial schema. 

I thought about developing my own code using the MetaDataAPI but looks like del function is not supported ?

https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/sforce_api_objects_customfield.htm

Jay



Jay
Best Answer chosen by Jay Janarthanan
Rajiv Bhatt 16Rajiv Bhatt 16
If you going to do this in Apex then i would highly recommend using the "Apex Wrapper Salesforce Metadata API" by Andrew Fawcett, it has a method to delete custom fields: 
https://github.com/financialforcedev/apex-mdapi

Check deleteField() method on this page https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataServiceExamples.cls
Another alternative is: 
http://salesforce.stackexchange.com/questions/68798/using-metadata-api-to-deploy-destructive-changes-to-delete-custom-fields