Preface – This post is part of “Salesforce Integration with SOAP API” series.

In this blog post, I will go through an example where I will use Java program to perform delete operation using Salesforce’s SOAP API. The Syntax is given below –

DeleteResult[] = connection.delete(ID[] ids);

You should consider the below points before using the delete operation. 

Note: I have written a helper class which I am using to connect to Salesforce using Enterprise WSDL. To know more about that, please refer my previous post @ 

Below is the Java program – where I am deleting an Account record with ID: 0019000000tvEQo.
import com.sforce.soap.enterprise.DeleteResult;
import com.sforce.soap.enterprise.EnterpriseConnection;
import com.sforce.soap.enterprise.Error;

public class DeleteAccount {
private EnterpriseConnection enterpriseConnection;

private DeleteAccount(){

public static void main(String[] args) {
DeleteAccount deleteAccount = new DeleteAccount();
deleteAccount.doDeleteAccount(new String[]{"0019000000tvEQo"});

private void doDeleteAccount(String ids[]){
DeleteResult[] deleteResults = getEnterpriseConnection().delete(ids);

for(DeleteResult eachDeleteResult : deleteResults){
System.out.println("Deleted record id: " + eachDeleteResult.getId());
for(Error eachError: eachDeleteResult.getErrors()){
System.out.println("Error occurred with message: " + eachError.getMessage());
}catch(ConnectionException e){

public EnterpriseConnection getEnterpriseConnection() {
return enterpriseConnection;

public void setEnterpriseConnection(EnterpriseConnection enterpriseConnection) {
this.enterpriseConnection = enterpriseConnection;


It’s super easy!!!. Please provide your feedback. Thanks.