You need to sign in to do that
Don't have an account?
How to remove custom fields using Metadata API (Bulk delete custom fields)
Hello,
I want to delete 500+ custom fields. Is there any solution to mass remove custom fields? I have tried with metadata Api using below code. But it gives me below error.
Object with id:04s900000037qo4AAA is InProgress
Error status code: INVALID_CROSS_REFERENCE_KEY
Error message: In field: members - no CustomField named Custom_Field__c found
Object with id:04s900000037qo4AAA is Error
Below is the code:
public 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);
}
private void printAsyncResultStatus(AsyncResult[] asyncResults) throws Exception {
if (asyncResults == null || asyncResults.length == 0 || asyncResults[0] == null) {
throw new Exception("The object status cannot be retrieved");
}
AsyncResult asyncResult = asyncResults[0]; //we are creating only 1 metadata object
if (asyncResult.getStatusCode() != null) {
System.out.println("Error status code: " +
asyncResult.getStatusCode());
System.out.println("Error message: " + asyncResult.getMessage());
}
System.out.println("Object with id:" + asyncResult.getId() + " is " +
asyncResult.getState());
}
Is there any other solution (any app) to removing custom fields?
Thanks in advance,
Dhaval Panchal
Using ANT and SFDC Migration tool I am now able to delete bulk custom fields.
Download Apache Ant using below link:
Extract and copy this folder where you want to keetp (i have copied this folder to "C" drive : C:\apache-ant-1.9.2)
Set path in environment variables for ant.
To set environment variables
-> Right click on My Computer -> Property -> Advance System Setting -> Click on Environment variables button.
-> click on System variables -> Click on New -> Give variable name = ANT_HOME and variable value = [your and path]
see below images.
Now go to your salesforce account
click on
Setup -> Develop -> Tools -> Force.com Migration Tool.
Download "salesforce_ant_28.0" and extract this zip file.
You will file "ant-salesforce.jar" file in extracted folder, copy this
jar file to "C:\apache-ant-1.9.2\lib"
Now go to folder salesforce_ant_28.0 -> sample
open file "build.properties" and provide your username, password and token there.
In sample folder you will find xml file formates using that you can deploy components.
All Answers
Hi,
There is no solution I am aware of to delete custom fields programmatically. You cannot delete/remove fields using metedata API directly.
But check out this Thread, for a work around:
http://boards.developerforce.com/t5/General-Development/Delete-custom-fields-with-metadata-api-eclipse/td-p/165945
Using ANT and SFDC Migration tool I am now able to delete bulk custom fields.
Download Apache Ant using below link:
Extract and copy this folder where you want to keetp (i have copied this folder to "C" drive : C:\apache-ant-1.9.2)
Set path in environment variables for ant.
To set environment variables
-> Right click on My Computer -> Property -> Advance System Setting -> Click on Environment variables button.
-> click on System variables -> Click on New -> Give variable name = ANT_HOME and variable value = [your and path]
see below images.
Now go to your salesforce account
click on
Setup -> Develop -> Tools -> Force.com Migration Tool.
Download "salesforce_ant_28.0" and extract this zip file.
You will file "ant-salesforce.jar" file in extracted folder, copy this
jar file to "C:\apache-ant-1.9.2\lib"
Now go to folder salesforce_ant_28.0 -> sample
open file "build.properties" and provide your username, password and token there.
In sample folder you will find xml file formates using that you can deploy components.
About BOFC:
Helps Admins & Developers to CREATE multiple, DELETE multiple fields, EXPORT Object - Fields Detail & Assign FLS for multiple profiles for multiple fields in single click
Features:
For AppExchange:
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000000qDqqEAE
Kindly share your valuable inputs/feedback or let me know, if you need any assistance.
You can contact me:
Email: mishu67777@gmail.com
Mobile: +91-9953170767