1

I'm trying out following code to find duplicate leads based on email ID:

    SObject[] inputSObjectArray = new SObject[1];
    // Instantiate an empty Java SObject
    SObject searchCriteria = new SObject();
    // Set its type to Lead.
    searchCriteria.setType("Lead");
    // Set Email field.
    searchCriteria.setField("Email", lead.getField("Email"));
    // Add the sObject to the input array
    inputSObjectArray[0] = searchCriteria;

    Connection.getInstance().getConnection().setDuplicateRuleHeader(false, false, false);

    FindDuplicatesResult[] callResults = null;

    try {
        callResults = Connection.getInstance().getConnection().findDuplicates(inputSObjectArray);
    } catch (ConnectionException e) {
        e.printStackTrace();
    }

    if (callResults != null && callResults.length > 0) {
        // print results
        System.out.println(callResults.length);
    }

But I'm getting following response from the API:

[ UnexpectedErrorFault [ ApiFault exceptionCode = 'NO_ACTIVE_DUPLICATE_RULE' exceptionMessage = 'Configuration error: No duplicate rules are defined for the Lead object.' extendedErrorDetails = '{[0]}' ] ]

I'm using partner WSDL jar in my Java project.

0

Never mind. I needed to create a Duplicate Rule in the SalesForce UI associated with the Leads.

I created a duplicate rule and activated it. Then I tried my same code and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.