You need to sign in to do that
Don't have an account?
aolivencia
Delete custom fields with metadata api + eclipse
Hi,
is it possbile to delete custom fields from a custom objects by using the metadata api in eclipse ?
Currently when I do this, the .object files is refreshed with the previous content.
Thanks in advance
I believe the issue here is that the 16.0 Metadata API does not support deleting custom fields. If I recall, that was added in 17.0. The latest Force.com IDE release right now is 16.0.
So today you could use the Force.com Migration Tool for Ant (instead of the IDE) to deploy your destructiveChanges.xml file against the 17.0 API.
The Force.com IDE for Spring '10 (18.0 API) is coming soon, and when it's released what I described above should work.
Jon
salesforce.com Product Manager
All Answers
You cannot delete fields from the Force.com IDE simply by removing the field definition from the .object file and saving it. The Metadata API requires an explicit delete command. This is easy to do from Eclipse for atomic files like Apex classes, where one file = one component, so you just have to delete the file.
For metadata types like CustomObject where one file can contain multiple first-class components, the Force.com IDE doesn't have a straightforward way in the UI to issue that delete command.
One option is to create a new file in the "src" folder called "destructiveChanges.xml". The format of this file is the same as package.xml (as documented in the Metadata API developer's guide, the Force.com Migration Tool Guide, and elsewhere). However, when you deploy (save) this file to the server, the components you list will be deleted instead of saved.
Admittedly this is a bit clunky, but we're aware of the issue and looking at ways to simplify the overall metadata experience.
Jon
salesforce.com Product Manager
Hi, I don't know why what you told me is not working. This is my custom object:
Custom object Employee__c:
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<deploymentStatus>Deployed</deploymentStatus>
<description>Company employee. test</description>
<fields>
<fullName>first_name__c</fullName>
<label>First Name</label>
<length>255</length>
<type>Text</type>
</fields>
<fields>
<fullName>last_name__c</fullName>
<label>Last Name</label>
<length>255</length>
<type>Text</type>
</fields>
<label>Employee</label>
<nameField>
<label>Custom Object Label Name</label>
<type>Text</type>
</nameField>
<pluralLabel>Employees</pluralLabel>
<searchLayouts/>
<sharingModel>ReadWrite</sharingModel>
</CustomObject>
Later I have uploaded my destructiveChanges.xml on the src folder ( at the same level of package.xml ) as you adviced me :
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Employee__c.last_name__c</members>
<name>CustomField</name>
</types>
<version>18.0</version>
</Package>
As you can see, I want to delete last_name__c
The problem is that after I upload destructiveChanges.xml, last_name__c is not deleted.
I have implemented the same approach described here: http://www.salesforce.com/us/developer/docs/api_meta/Content/manifest_samples.htm
Do you know why I cannot delete the field ?
Thanks in advance.
Hi, does anyone know about how solve my problem ?
Thanks
I believe the issue here is that the 16.0 Metadata API does not support deleting custom fields. If I recall, that was added in 17.0. The latest Force.com IDE release right now is 16.0.
So today you could use the Force.com Migration Tool for Ant (instead of the IDE) to deploy your destructiveChanges.xml file against the 17.0 API.
The Force.com IDE for Spring '10 (18.0 API) is coming soon, and when it's released what I described above should work.
Jon
salesforce.com Product Manager
"The Force.com IDE for Spring '10 (18.0 API) is coming soon, and when it's released what I described above should work."
Do you know if now we are able to delete custom fields with the new IDE version ?
Hi, I was looking back at this thread, and had a question. Jon, are you suggesting that this destructive changes file could be saved directly to a production instance in Eclipse, or only a sandbox? In general, we can't directly save files to production, and it's not clear how one would deploy a file like that.
I'm trying to figure out the best way to propogate a bunch of field deletions I just did in a sandbox to production.
Thanks!
I am having this same problem in production using Force.com IDE version 23.0. Are you saying that you can not delete fields from a custom object in this version as well?
Agreed, deploying destructiveChanges.xml from Eclipse still does not seem to work; I get the error message "Component type not permissable in destination organization" when I try to delete custom fields on a custom object in a development sandbox.
Salesforce BULK Object Field Creator - A Time Saver App....!!!
Helps Admins & Developers to create multiple fields, Delete Multiple Fields & Assign FLS for multiple profiles for multiple fields in single click
Drag Drop a csv or xls files which contains list of new fields to be created
App will restrict user to create fields which already exists in system.
Benefits:
1. Bulk(multiple) Field Creation
2. Bulk(multiple) Field Deletion
3. Export Object, Fields, Profiles Details
AppExchange Link:
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000000qDqqEAE
I was searching for something like updating th API name from eclipse.
When I try to delete with ANT, it's throwing the same error. Is there a way to use ANT or some other api tool to force remove this field (some salesforce equivalent to rm -f?? I have a ticket open, but with standard support I'm getting nowhere...
C:\Users\jsmith\Downloads\salesforce_ant_41.0\build.xml:23:
*********** DEPLOYMENT FAILED ***********
Request ID: 0Af0t000004VR0zCAG
All Component Failures:
1. objects/Client_Household__c.object (ExpECM__Client_Household__c.Primary_Contact__c) -- Error: This custom field is referenced elsewhere in salesforce.com. : Apex Class - ExpECM__ExpContactTriggerClass. This custom field is referenced elsewhere in salesforce.com. : Apex Class - ExpECM__ExpCaseParticipationTriggerClass.
*********** DEPLOYMENT FAILED ***********
at com.salesforce.ant.DeployTask.logFailedDeploy(DeployTask.java:178)
at com.salesforce.ant.DeployTask.handleResponse(DeployTask.java:150)
at com.salesforce.ant.SFDCMDAPIAntTaskRunner.runTask(SFDCMDAPIAntTaskRunner.java:92)
at com.salesforce.ant.DeployTask.execute(DeployTask.java:63)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:448)
at org.apache.tools.ant.Target.performTasks(Target.java:469)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1370)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:849)
at org.apache.tools.ant.Main.startAnt(Main.java:228)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:283)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
Total time: 23 seconds