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
JPClarkJPClark 

Metadata API, Delete fields and erase fields

I'm using the metadata API and deleting some of the custom fields on custom sobjects. I'm able to get them deleted, but when I go into SalesForce Web, I then have to erase the deleted fields.

 

Is there any way to programatically erase the fields also?

 

 

Here's the code that is deleting the fields.

private List<AsyncResult> ThrottledDelete(List<Metadata> deleteItems, int ThrottleSize) { List<AsyncResult> AllResults = new List<AsyncResult>(); while (deleteItems.Count() > 0) { List<Metadata> SmallList; if (deleteItems.Count() < ThrottleSize) { SmallList = deleteItems; deleteItems = new List<Metadata>(); } else { SmallList = deleteItems.GetRange(0, ThrottleSize); deleteItems = deleteItems.Except(SmallList).ToList(); } AsyncResult[] results = metaService.delete(SmallList.ToArray()); results = WaitForResults(results, 1000); AllResults.AddRange(results); } return AllResults; }

 

 

Thanks for any input,

Jeff

CTU007CTU007

Hi, I need to delete 100+ custom fields from a custom object, would you explain how to use your code?

 

So after 45 days, will the field definition also be permanently deleted?

 

 

You will have 45 days to undelete this field to restore the field and all data stored in it, and after that time it and all data stored in it will be automatically permanently deleted.

Mat SchafferMat Schaffer

Did you ever find a solution here?

 

We've found that you can leave one deleted (but not yet erased) fields there, but once you delete the second and try to re-add a third with the same name you get an error.

 

This is fairly annoying when deploying/undeploying test code to test the initial installation case. Half tempted to write something that'll submit the form over HTTP.

 

-Mat

JPClark3JPClark3

I never did get this to work correctly. I gave up and just delete them by hand (and of course grumble about it.