Hot answers tagged

29 votes
Accepted

How to delete a Test Class WITHOUT using eclipse

You can do this with only the software that comes installed with Windows/Linux/Mac. These instructions will be for Windows. Create a Folder Make a folder on your desktop. You'll want this so you can ...
user avatar
  • 438k
11 votes

Delete Operation Too Large - but all related records have been deleted

You must wait between several days up to a week in order to delete the parent record. Even if you empty the recycle bin, the records are not "permanently" deleted until some reaper job on the ...
user avatar
  • 2,335
11 votes

How to delete AsyncApexJob with Queued status

In case Phil's solution doesn't work, and you are stuck with a zombie Queued AsyncApexJob, here's a workaround: At Version 39.0, an attempt to delete a zombie Queued AsyncApexJob that has no ...
user avatar
  • 63k
11 votes
Accepted

Deleting Users from Salesforce permanently

As of today, there's still no way to do that. You can, however vote on this idea, that's currently on review.
user avatar
11 votes
Accepted

Deleting (or Renaming) Custom Metadata Object / Custom Object yields Insufficient Privileges

This is an issue under investigation by SFDC R&D that apparently affects some customers and is not limited to just Custom Metadata deletion (affects also Custom Object deletion including hard ...
user avatar
  • 63k
10 votes
Accepted

Delete an SObject by knowing only Id

Yes, you can delete an object knowing only its Id. If you know the object's type at development time, you can initialize an sObject instance with the Id and supply it to the delete DML operator, as ...
user avatar
  • 87.3k
9 votes

How to delete a class from production using destructiveChanges.xml

From this blog To achieve this via Workbench, create a folder on your desktop. I will call my folder ‘deleteClasses’. Then go to Notepad (or another text editor) and copy and paste the below and save ...
user avatar
  • 13.3k
9 votes
Accepted

Is the LastModifiedDate of a deleted record the date that it was deleted?

Thanks to @AdrianLarson for the suggestion, but SystemModStamp got me the same answer as LastModifiedDate. The user with the anecdote has just confessed to being confused and misreporting the ...
user avatar
  • 12.9k
8 votes
Accepted

Need assistance on scheduled jobs

Deleting the scheduled job is enough. It will not run again. You can also delete using code. for (CronTrigger ct : [SELECT Id FROM CronTrigger WHERE CreatedBy.Name='xxx']) { System.abortJob(ct....
user avatar
  • 3,974
8 votes
Accepted

What is best way to delete all records from any Dev org

It would be pretty straightforward to write a minimum viable batch to clear one table at a time for this scenario: public class DeleteAllBatch implements Database.Batchable<SObject> { final ...
user avatar
  • 144k
7 votes
Accepted

How to delete AsyncApexJob with Queued status

If it's queued that implies its scheduled, therefore you should be able to get the Job ID and abort it, e.g. System.abortJob(jobId);
user avatar
7 votes
Accepted

How can I delete a contact which was associated with a customer portal user?

Just to add to @John Thompson's answer, you can add the button that disables the customer user: This will remove the connection between the user and the contact, and mark the user as deleted. If you ...
user avatar
  • 4,799
7 votes
Accepted

How to Delete a Data Extension Folder

Try to delete it from Email Studio: Go to Email Studio > Subscribers > Data Extensions and right click on the folder.
user avatar
  • 10.6k
6 votes
Accepted

Truncate or delete all records in a custom object

You can't perform any DML using SOQL. The 'Q' stands for 'Query'. If you want to use Execute Anonymous, then you can use: delete [select id from myobject__c limit 10000]; However, this has a 10,000 ...
user avatar
  • 438k
6 votes

how to delete a record using apex:outputLink

If you want to delete a record then use URLFOR instead of statically giving url for your destination. You can achieve it in a much simpler way. Use this code:- <apex:outputLink value="{!URLFOR($...
user avatar
6 votes

delete records from multiple objects via apex batch class

You can combine up to 10 types of SObject in one list for DML as long as they are grouped by type. See this post by Jesse Altman for more color on that. You can accomplish what you are looking for by ...
user avatar
  • 144k
6 votes

How to restore permanently deleted records?

Update: As of July 31, 2020, Data Recovery service has been retired and no longer available as a service. So now we don't have any way to get deleted records unless we have some backups. Data Recovery ...
user avatar
6 votes
Accepted

Before Delete Trigger, Need to Delete Linked Record, getting "De-reference Null Object" Error

This is happening because Trigger.new is not available on before delete context. You'll want to use Trigger.old instead. Check this document about Trigger Context Variables.
user avatar
6 votes
Accepted

Delete classes/trigger from Prod via VSCode

The UI option currently does not support deletion of metadata from production (e.g. see this question) What you need to do is a normal metadata API deployment instead. Create a new folder in your ...
user avatar
  • 438k
6 votes
Accepted

Mass delete Debug logs using Salesforce DX

The following worked for me sfdx force:data:soql:query -q "SELECT Id FROM ApexLog" -r "csv" | out-file -encoding oem out.csv sfdx force:data:bulk:delete -s ApexLog -f out.csv With ...
user avatar
  • 148
5 votes
Accepted

Mass Deletion Of (most) Records (in Sandbox) (100 million+)

Write a chained batchable class: public class KillMostBatch implements Database.Batchable<SObject> { public Database.QueryLocator start(Database.BatchableContext context) { return ...
user avatar
  • 438k
5 votes
Accepted

Database.DeleteResult.getErrors() question

When you are calling Database.delete it is returning a List of Database.DeleteResult records if you are doing it to a list. There are several things that could cause only 1 record to be returned here....
user avatar
  • 6,059
5 votes
Accepted

delete records from multiple objects via apex batch class

Here's how I decided to implement my requirement. Still need to test it, but high level seems to be working: global class DeleteRecords implements Database.Batchable<string>, Database.Stateful ...
user avatar
  • 325
5 votes

How can I permanently delete a record whose isdeleted="true"

The system doesn't immediately purge deleted records once you empty the Recycle Bin. Instead, they're flagged for purging, which runs periodically in the background. Your record will be gone after the ...
user avatar
  • 438k
5 votes

Why is this trigger to prevent event deletion not executing correctly?

+1 for Adrian's answer. But when adding triggers to standard objects that are likely to be used by many apps in an org, it makes sense to not penalize those other apps with extra SOQL calls. So for ...
user avatar
  • 130k
5 votes
Accepted

Deletion of Managed Package in Dev Org

You would need to log a ticket with salesforce, as you cannot deprecate the latest version of the managed package. Please use this link if you want to learn more about the packages: https://help....
user avatar
  • 1,415
5 votes
Accepted

Remove elements from Map based on records in another map

You can use the remove() method: Map <String, String> mapOne = new Map <String, String>(); mapOne.put('key1', 'value1'); mapOne.put('key2', 'value2'); mapOne.put('key3', 'value3'); mapOne....
user avatar
5 votes
Accepted

How prevent deletion in Event delete trigger and update a field instead

You cannot convert the delete event into an update. Once the DML operation has been started, you can block it (and potentially roll back the transaction) by adding an error on the record. That's ...
user avatar
  • 87.3k
5 votes
Accepted

Does contact deletion in marketing cloud also removes email tracking data?

The information will remain in the system - but in unrecognizable format. Contact deletion does also not remove the Contact (any any related information) from your custom non-sendable Data ...
user avatar
  • 5,447
5 votes
Accepted

Error not bubbling up from delete trigger

You will need to use Trigger.old in case of delete operation to be able to display your custom error message. This is from the Trigger Exceptions documentation (emphasis mine): Triggers can be used ...
user avatar
  • 29.2k

Only top scored, non community-wiki answers of a minimum length are eligible