Sunday, March 1, 2015

Salesforce Integration with SOAP API - Part 10 - Delete operation using Java program

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.


  1. With cloud computing, you eliminate those headaches because you’re not managing hardware and software—that’s the responsibility of an experienced vendor like The shared infrastructure means it works like a utility: You only pay for what you need, upgrades are automatic, and scaling up or down is easy. Thanks for sharing this in here.

    Salesforce course in chennai
    Salesforce developer training in chennai

  2. Well post in recent day’s customer relationship play vital role to get good platform in business industry, Salesforce crm tool helps you to maintain your customer relationship enhancement.
    Salesforce training in Chennai|Salesforce training institute in Chennai