[JAVA] Create a tool for name identification in Salesforce


Salesforce has a merge function, but I don't think it has a function to systematically output candidate materials for name identification. I wrote a memo when I made a very simple name identification tool in Java.

Tool contents


1. Use WSC to create a Salesforce Jar file for your environment

Java command

java -jar target/force-wsc-42.0.0-uber.jar <inputwsdlfile> <outputjarfile>
Example) java-jar target/force-wsc-42.0.0-uber.jar wsdl.xml original.jar

2. Create a project in Eclipse




package sfdc.api;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Calendar;

import com.sforce.soap.enterprise.EnterpriseConnection;
import com.sforce.soap.enterprise.QueryResult;
import com.sforce.soap.enterprise.sobject.Account;
import com.sforce.soap.enterprise.sobject.SObject;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;

 * Salesforce Connect
public class App
    public static void main( String[] args )
    	ConnectorConfig config = new ConnectorConfig();
    	config.setUsername("Login ID");
    	config.setPassword("Password + security token");
    	//The version of Soap service will be updated, so refer to the following site
    	// https://help.salesforce.com/articleView?id=000126966&language=ja&type=1
    	String soapEndpoint = "https://login.salesforce.com/services/Soap/c/40.0";

       try {
    	   EnterpriseConnection connection = new EnterpriseConnection(config);
    	   QueryResult queryResults = connection.query("SELECT Id,Name,LastModifiedDate FROM Account Order by Name");
    	   SObject[] records = queryResults.getRecords();
    	   String beforeId = "";
    	   String beforeName = "";
    	   for(SObject record : records) {
    		   String name = ((Account) record).getName();
			   String id = ((Account) record).getId();
			   Calendar lastModifiedDate = ((Account) record).getLastModifiedDate();
	   		   System.out.println("sfid{" + id + "}");
			   if(name.equals(beforeName)) {
				   fileWriter("Duplicate[" +  beforeName + "], sfid{" + beforeId + "}");
				   fileWriter("Duplicate[" +  name + "], sfid{" + id + "}");
			   beforeId = id;
			   beforeName = name;

    	} catch (ConnectionException ce) {

    private static void fileWriter(String name) {
        try {
            File f = new File("nayose.txt");
            BufferedWriter bw = new BufferedWriter(new FileWriter(f, true));
          } catch (IOException e) {

Duplicate[Taro Tanaka], sfid{0017F10xxxxxxxxxx}
Duplicate[Taro Tanaka], sfid{0015A02xxxxxxxxxx}

Recommended Posts

Create a tool for name identification in Salesforce
Create a name input function
Create a MySQL container for application testing in Ansible AWX
Create a database in a production environment
Create a Servlet program in Eclipse
Create a fluentd server for testing
How to create a Maven repository for 2020
Have a tool to create and open a new canvas in Mac preview
Create a Docker container for your development web server in Ansible on MacOS
Create an animation in which characters emerge for a moment using molecular dynamics
I made a Diff tool for Java files
How to create a database for H2 Database anywhere
Create a CSR with extended information in Java
Create a simple batch processing framework in Eclipse.
Try to create a bulletin board in Java
How to create pagination for a "kaminari" array
Let's create a custom tab view in SwiftUI 2.0
A tool for hitting arbitrary SQL using JDBC
Let's create a super-simple web framework in Java
How to create a theme in Liferay 7 / DXP
[Java] Let's create a mod for Minecraft 1.16.1 [Introduction]
How to easily create a pull-down in Rails
Make a snippet for Thymeleaf in VS Code
[Java] Let's create a mod for Minecraft 1.14.4 [99. Mod output]
Create a docker environment for Oracle 11g XE
Create a native extension of Ruby in Rust
[Java] Let's create a mod for Minecraft 1.14.4 [0. Basic file]
[Java] Let's create a mod for Minecraft 1.14.4 [4. Add tools]
How to create a Java environment in just 3 seconds
I made a check tool for the release module
[Java] Let's create a mod for Minecraft 1.14.4 [5. Add armor]
[Java] Let's create a mod for Minecraft 1.14.4 [Extra edition]
[Java] Let's create a mod for Minecraft 1.14.4 [7. Add progress]
[Java] Let's create a mod for Minecraft 1.14.4 [6. Add recipe]
Create a widget template for iOS14 with Intent Configuration.
How to create a Spring Boot project in IntelliJ
[Java] Let's create a mod for Minecraft 1.16.1 [Basic file]
I tried to create a Clova skill in Java
[Java] Let's create a mod for Minecraft 1.14.4 [1. Add items]
How to create a data URI (base64) in Java
Try Easy Ramdom, a PropertyBase Testing tool for java
A note for Initializing Fields in the Java tutorial
Create UnsafeMutablePointer <UnsafeMutablePointer <Int8>?>! In Swift for C char ** hoge
[Programming complete] §5 Create a review management app in Ruby
[Java] Let's create a mod for Minecraft 1.14.4 [2. Add block]
Create a frameless non-rectangular window in JavaFX without a taskbar
I want to create a generic annotation for a type
[Java] Let's create a mod for Minecraft 1.16.1 [Add block]
Create API key authentication for Web API in Spring Security
Install Liferay 7 / DXP (Windows)
How to create a service builder portlet in Liferay 7 / DXP