17
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 ...
13
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 ...
12
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 ...
11
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 ...
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 ...
9
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 ...
8
votes
Mass delete Debug logs using Salesforce DX
The following worked fine for me in MAC
sfdx force:data:soql:query -q "SELECT Id FROM ApexLog" --resultformat csv > out.csv
sfdx force:data:bulk:delete -s ApexLog -f out.csv
I have not ...
7
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.
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.
7
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 ...
7
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 ...
5
votes
Accepted
How can we find out the deleted record in After delete trigger?
To get or Query deleted records you need to use ALL ROWS So your query will be
List<Object__c> deletedRecords = [SELECT Id FROM Object__c WHERE ID IN :lstTriggerOld AND ID NOT IN : ...
5
votes
Remove elements from Map based on records in another map
A clear and efficient solution would be by using keySet() and removeAll() methods.
Explanation:
map.keyset() will return a reference to the set of keys of the respective map, enabling the interface to ...
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....
5
votes
Deleting Custom Objects
When you go to the "Custom Fields & Relationships" section of the custom object definition, there will be a bold link labeled "Deleted Fields (#)". If you click on that link, it will take you to a ...
5
votes
Does Database.SaveResult, Database.DeleteResult, etc. implement a public interface?
No, they do not implement a common interface. As a workaround to this, I created a wrapper class that does this:
class DmlResult {
Id recordId;
Integer rowIndex;
Boolean success;
...
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 ...
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 ...
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 ...
5
votes
ERROR: must implement the method: System.Iterable<SObject> Database.Batchable<>.start(Database.BatchableContext)
It's a weird behavior with the compiler. Change it to Database.Batchable<sObject> instead.
Notes:
You don't need to copy the list before deleting it.
Use an inline query.
Don't query fields you ...
5
votes
Can't delete flow version because it's referenced by deleted flow interviews
I ran into this issue, although I had no paused flow intervals. Salesforce has saved failed flow interviews which would not let me delete my flow. Solved by navigating to Setup -->Paused and Failed ...
4
votes
Validation rule prevent user deleting record in pipelines?
The only way to validate deletion is with an Apex Trigger. To validate a record and prevent its deletion, you need to call addError.
The most basic working structure would look like:
trigger ...
4
votes
Delete a managed release package
You can contact Salesforce support to request that a managed - released version be reverted to a managed - beta status if it is not installed in any orgs. If you want to rollback a specific version ...
4
votes
Accepted
AccountHistory not deleting immediately after an update
History records are not created until the end of the transaction. If you want to make sure those records are available for deletion, use a @future method, instead.
4
votes
Limitations when using ALL ROWS in query
Records once deleted reside in the recycle-bin, and they stay there for 15 days unless to forcefully delete them.
Deleted records remain in the recycle bin for 15 days, and can be
restored during ...
4
votes
Is there some event to delete record from Lightning component like e.force:deleteRecord
we can use force:recordData to delete the record in Lighting Component.
To delete a record using Lightning Data Service, call deleteRecord on the force:recordData component, and pass in a callback ...
4
votes
UpsertData and DeleteData not working
I recently faced a very similar issue. It turned out that the UpsertData function was trying to create a row without providing a value of a required variable. To avoid this, one needs to make sure ...
4
votes
Revoke access to delete a specific Account record type
Kevin,
You want to obtain the recordtype involved first, you can do it this way
Id prospectRecordTypeId = Account.SObjectType.getDescribe().getRecordTypeInfosByDeveloperName().get('Prospect')....
4
votes
Does contact deletion in marketing cloud also removes email tracking data?
There are two methods of deleting contacts:
1) Contact Deletion via Contact Builder
This is a full hard delete and will NOT retain individual tracking data such as opens, clicks etc. However it ...
4
votes
Accepted
Override Standard Delete Action on Account Object
You cannot override the delete action.
You need to remove the Delete permission for Account for those Profiles which you wish to disallow from this action. (This Trailhead project implements the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
delete × 295apex × 68
trigger × 46
custom-object × 18
soql × 16
bulk-delete × 16
marketing-cloud × 11
visual-workflow × 11
before-trigger × 11
visualforce × 10
managed-package × 10
batch × 9
permissions × 9
contact × 9
class × 8
dml × 8
record × 8
rest-api × 7
custom-field × 7
profile × 7
lightning-aura-components × 6
community × 6
dataextensions × 6
master-detail × 6
unit-test × 5