Hot answers tagged

28

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 keep your files in order. Create package.xml Open Notepad (Start > Accessories > Notepad). Copy the following text into the text editor: <?xml version="1....


18

Fulfill the PreRequisites for using the Force.com Migration tool Install the Java JRE/ JDK Install Apache Ant Copy the ant-salesforce.jar file from the unzipped file into the ant lib directory. Follow the steps at Apex deploying using Ant to understand the basic setup Construct your destructiveChanges.xml file using Propagating Destructive Changes Sample: ...


11

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


10

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 Salesforce side runs to truly delete them. If you're in a rush, you can open a case with Salesforce asking to "run a physical delete" on your org. They will require ...


10

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 associated CronTrigger using System.abortJob(theAsyncApexJobId) fails with: System.StringException: You can’t abort scheduled Apex jobs by calling System....


9

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 you show: Contact ct = new Contact(Id = del); delete ct; If you don't know the object's type, you can pass the Id directly to Database.delete(), which as you ...


8

Using force.com migration tool with ANT allows you to deploy destructivechanges.xml. http://www.salesforce.com/us/developer/docs/daas/index.htm The sample package provided includes a destructive changes example. Advantages of using this over doing it straight from Eclipse are: You can replicate the operation against different sandboxes / production by ...


8

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.Id); }


8

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 SObjectType deleteType; public DeleteAllBatch(SObjectType deleteType) { this.deleteType = deleteType; } public Database.QueryLocator start(Database....


7

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);


7

If its a lookup you will need a simple trigger to do this in real time trigger onParentObjectDelete on CustomObject__c (before delete){ List<Id> idsToQuery = new List<Id>{}; for(CustomObject__c a: Trigger.new){ idsToQuery.add(a.id); } //query all child records where parent ids were deleted ChildObject__c[] objsToDelete = [select id from ...


6

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 as the file with ‘package.xml’ and ‘All files (.)’. <?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"&...


6

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($Action.Account.delete, account.id)}" onclick="return window.confirm('Are you sure?');">Delete</apex:outputLink> Hope it will help.


6

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 using an Iterable. Take a look here for a good example of how to use an Iterable in a batch (at the bottom). You will want to iterate over a List<SObject>...


6

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 situation on 2017-07-21. Which makes me think that LastModifiedDate is going to be the date of deletion. It would be a bit crazy to be anything else. I'll leave this ...


6

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.


6

Try to delete it from Email Studio: Go to Email Studio > Subscribers > Data Extensions and right click on the folder.


5

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. 1) If you are calling Database.delete inside a query on each individual record, you will only get 1 error returned. for (Account acc: scope) { Database....


5

Write a chained batchable class: public class KillMostBatch implements Database.Batchable<SObject> { public Database.QueryLocator start(Database.BatchableContext context) { return Database.getQueryLocator([SELECT Id FROM MyObj__c LIMIT 20000000]); } public void execute(Database.BatchableContext context, MyObj__c[] scope) { ...


5

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 row limit, so that might not be appropriate in all cases. Salesforce can query 50,000 records at a time but due to governor limit it'll allow only 10,000 DML ...


5

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 { global boolean bReRun = false; //will be used to determine if batch has to re-run in case there are more that 10K of records global Iterable<string> ...


5

+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 this case something like the code below will only do the query when necessary: trigger PreventEventDeletion on Event (before delete) { Set<Id> ...


5

I don't think that's possible without Salesforce support. You need to contact them and they will charge you some amount and maybe then you will get your records back. As per Salesforce docs Because of the manual intervention, there is a cost. The cost is relative to the amount of manual work and time needed to perform the recovery. The price for this ...


5

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 don't have this button - you can add it to your layout from the page layout editor: After removing the connection between the contact and the user you can ...


5

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.put('key4', 'value4'); Map <String, String> mapTwo = new Map <String, String>(); mapTwo.put('key1', 'value1'); mapTwo.put('key2', 'value2'); for (...


5

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 unlikely to be what you want to do here. Instead, I'd suggest you build your delete trigger to create a new Event (or Task), copying fields from the deleted ...


5

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 Extensions, Send Logs and FTP files. Email Studio Tracking Tracking data for deleted subscribers and contacts are retained in anonymized format and cannot be ...


5

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 to prevent DML operations from occurring by calling the addError() method on a record or field. When used on Trigger.new records in insert and update triggers, ...


5

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 project, then create two new files in this folder, package.xml and destructiveChanges.xml. package.xml <?xml version="1.0" encoding="UTF-8"?> <Package ...


4

The fastest way to do this is by adding your Production org in Force.com IDE / Eclipse and delete the class via the IDE. You will have to make sure that no dependencies exist before deleting, else the delete will fail. Remove the dependencies by deleting the class first in your sandbox, then seeing why the delete would fail, do those changes, deploy it to ...


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