function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
learnSFlearnSF 

Record DeDup 1.4 is not working in firefox

Hi,
 
I tried this tool in firefox and IE. In IE its working fine but in firefox its just hang and giving searching result.....message as user describe in review.
 
Can some one point out how to get this problem solved in firefox.
RFLRFL
For some reason Salesforce has not updated Record DeDup to work with a non-beta version of the Ajax toolkit.   The link below is  my version of Record DeDupe which will work for Firefox 3, it has been upgraded to Ajax toolkit version 14 and has some added address fields. 

https://login.salesforce.com/?startURL=%2Fpackaging%2FinstallPackage.apexp%3Fp0%3D04t70000000K9Vm

RFLRFL
In case you can't reach my version on app exchange here is the code.  It must be split because it exceeds 20000 characters.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<!--
 AJAX S-Control to search SPR for Customer Information and create new Account/Contact/Lead if matching record not found in salesforce.com
 
   Salesforce bug?:  If an existing record has an asterisk in a field it will always be found by the search function !!!
  
 -->
<link href="/dCSS/Theme2/default/common.css" type="text/css"
  rel="stylesheet">
<script
  src="/soap/ajax/14.0/connection.js" type="text/javascript"></script>
<script language="JavaScript1.2" src="/js/functions.js"></script>

<script id="getSearchCriteria()">
function getSearchCriteria()
{
  // Create the search string
  // Special handling of first and last name
  var fullName = document.getElementById("first_name").value;
  var lastName = document.getElementById("last_name").value;
  if (fullName != "") {
    if (lastName != "") {
      fullName = fullName + lastName; // "* " + lastName;
    }
  } else {
    fullName = lastName;
  }

  var fullSearchString = "";
  var phone = document.getElementById("phone").value;
  //phone = phone.replace(/[()\.\- ]/g, "*");
  var location1 = document.getElementById("street").value + " * " + document.getElementById("city").value;
    + " * " + document.getElementById("country").value;
 
  fullSearchString = appendToSearchString(fullSearchString, fullName);
  fullSearchString = appendToSearchString(fullSearchString, document.getElementById("company").value+"*");
  fullSearchString = appendToSearchString(fullSearchString, phone);
  fullSearchString = appendToSearchString(fullSearchString, document.getElementById("email").value);
  fullSearchString = appendToSearchString(fullSearchString, location1);

  // Check to see if the user entered anything
  if (fullSearchString.length === 0) {
    alert("No Search Criteria Supplied");
    return null;
  }

  return fullSearchString;
}
</script>

<!--  **** This is the MAIN function ****  -->
<script id="searchTable(whowhat)">
// whowhat == fullSearchString
function searchTable(whowhat)
{
  var tablesFields = "contact(id, phone, email, firstname, lastname, accountId, mailingstreet, mailingcity, mailingstate, mailingcountry),"
    + " lead(id, phone, company, email, firstname, Status, lastname, street, city, state, country),"
    + " account(id, phone, type, name, billingstreet, billingcity, billingstate, billingcountry)";

  // and find exactly one, return the ID, otherwise fail and return null

  whowhat = whowhat.replace(/([\&\|\!\(\)\{\}\[\]\^~\:\\\+\-])/g, "\\$1");// escape reserved characters
  var sstr =    "find {" + whowhat + "*} in ALL FIELDS RETURNING "+tablesFields+""
  try { var sr = sforce.connection.search(sstr); }
  catch (error) {
    throw ( "Error: could not search: " + sstr + "\r\n");
  }
  return sr;
}
</script>

<script id="appendToSearchString(searchString, newValue)">
function appendToSearchString(searchString, newValue) {
  if (newValue.length > 0) {
    if (searchString.length === 0) {
      searchString = newValue;
    } else {
      searchString += " OR " + newValue;
    }
  }
  return searchString;
}
</script>

<script id="makeAccountListHolder()">
function makeAccountListHolder() {
  return "<div class='bRelatedList'>" +
    "<div class='bNext'><div class='withFilter'><div class='clearingBox'></div></div></div>" +
    "<table width=100%><tr><td><div class='listAccount'><div class='bPageBlock secondaryPalette'><div class='pbHeader'><table border='0' cellpadding='0' cellspacing='0'><tbody><tr><td class='pbTitle'><img src='/s.gif' alt='' title='' class='minWidth' height='1' width='1'><img src='/s.gif' alt='' class='relatedListIcon'><h3>Matching Accounts</h3></td><td class='pbHelp'></td></tr>" +
    "</tbody></table></div><div class='pbBody'><table class='list' border='0' cellpadding='0' cellspacing='0'><tbody><tr class='headerRow'>" +
    "<th scope='col' class=''>Account Name</th>" +
    "<th scope='col' class='PhoneNumberElement'>Phone</th>" +
    "<th scope='col' class='AddressElement'>Billing Address</th>" +
    "<th scope='col' class=''>Type</th>" +
    "</tr>";
}
</script>

<script id="makeLeadListHolder()">
function makeLeadListHolder() {
  return "<div class='bRelatedList'>" +
    "<div class='bNext'><div class='withFilter'><div class='clearingBox'></div></div></div>" +
    "<table width=100%><tr><td><div class='listLead'><div class='bPageBlock secondaryPalette'><div class='pbHeader'><table border='0' cellpadding='0' cellspacing='0'><tbody><tr><td class='pbTitle'><img src='/s.gif' alt='' title='' class='minWidth' height='1' width='1'><img src='/s.gif' alt='' class='relatedListIcon'><h3>Matching Leads</h3></td><td class='pbHelp'></td></tr>" +
    "</tbody></table></div><div class='pbBody'><table class='list' border='0' cellpadding='0' cellspacing='0'><tbody><tr class='headerRow'>" +
    "<th scope='col' class=''>Name</th>" +
    "<th scope='col' class=''>Company</th>" +
    "<th scope='col' class='PhoneNumberElement'>Phone</th>" +
    "<th scope='col' class=''>Email</th>" +
    "<th scope='col' class='AddressElement'>Address</th>" +
    "<th scope='col' class=''>Status</th>" +
    "</tr>";
}
</script>

<script id="makeContactListHolder()">
function makeContactListHolder() {
  return "<div class='bRelatedList'>" +
    "<div class='bNext'><div class='withFilter'><div class='clearingBox'></div></div></div>" +
    "<table width=100%><tr><td><div class='listContact'><div class='bPageBlock secondaryPalette'><div class='pbHeader'><table border='0' cellpadding='0' cellspacing='0'><tbody><tr><td class='pbTitle'><img src='/s.gif' alt='' title='' class='minWidth' height='1' width='1'><img src='/s.gif' alt='' class='relatedListIcon'><h3>Matching Contacts</h3></td><td class='pbHelp'></td></tr>" +
    "</tbody></table></div><div class='pbBody'><table class='list' border='0' cellpadding='0' cellspacing='0'><tbody><tr class='headerRow'>" +
    "<th scope='col' class=''>Name</th>" +
    "<th scope='col' class=''>Account</th>" +
    "<th scope='col' class='PhoneNumberElement'>Phone</th>" +
    "<th scope='col' class=''>Email</th>" +
    "<th scope='col' class='AddressElement'>Mailing Address</th>" +
    "</tr>";
}
</script>

<script id="makeLeadRow(obj)">
function makeLeadRow(obj) {
  var company = obj.get("Company");
  if (company == null) company = "&nbsp;";
  var email = obj.get("Email");
  if (email == null) email = "&nbsp;";
  var phone = obj.get("Phone");
  if (phone == null) phone = "&nbsp;";
   
  var street = obj.get("Street"); if (street==null) street = "";
  var city = obj.get("City"); if (city==null) city = "";
  var state = obj.get("State"); if (state==null) state = "";
  var country = obj.get("Country"); if (country==null) country = "";
  var location = street + "<br>" + city + " &nbsp;" + state + " &nbsp;" + country;

  return "<th scope='row' class='dataCell'><a href='/"+ obj.get("Id") +"?srPos=0&amp;srKp=00Q' target=_parent>"+ obj.get("FirstName") +" "+ obj.get("LastName") +"</a></th>" +
    "<td class='dataCell'>" + company + "</td>" +
    "<td class='dataCell'>"+ phone +"</td>" +
    "<td class='dataCell'>"+ email +"</td>" +
    "<td class='dataCell'>" + location + "</td>" +
    "<td class='dataCell'>" + obj.get("Status") + "</td>" +
    "</tr>";

}
</script>

<script id="makeContactRow(obj)">
function makeContactRow(obj) {
  var accountId = obj.get("AccountId");
  var accountName = "&nbsp;";
  if (accountId != null)
    accountName = "<a href='/" + accountId + "' target='_top'>" + getAccountName(accountId) + "</a>";
  var email = obj.get("Email"); if (email == null) email = "&nbsp;";
  var phone = obj.get("Phone"); if (phone == null) phone = "&nbsp;";
   
  var street = obj.get("MailingStreet"); if (street==null) street = "";
  var city = obj.get("MailingCity"); if (city==null) city = "";
  var state = obj.get("MailingState"); if (state==null) state = "";
  var country = obj.get("MailingCountry"); if (country==null) country = "";
  var location = street + "<br>" + city + " &nbsp;" + state + " &nbsp;" + country;

  return "<th scope='row' class='dataCell'><a href='/"+ obj.get("Id") +"?srPos=0&amp;srKp=00Q' target=_parent>"+ obj.get("FirstName") +" "+ obj.get("LastName") +"</a></th>" +
    "<td class='dataCell'>" + accountName + "</td>" +
    "<td class='dataCell'>"+ phone +"</td>" +
    "<td class='dataCell'>" + email + "</td>" +
    "<td class='dataCell'>" + location + "</td>" +
    "</tr>";
}
</script>

<script id="makeAccountRow(obj)">
function makeAccountRow(obj) {
  var phone = obj.get("Phone");
  if (phone == null) phone = "&nbsp;";
  var type = obj.get("Type");
  if (type == null) type = "&nbsp;";
   
  var street = obj.get("BillingStreet"); if (street==null) street = "";
  var city = obj.get("BillingCity"); if (city==null) city = "";
  var state = obj.get("BillingState"); if (state==null) state = "";
  var country = obj.get("BillingCountry"); if (country==null) country = "";
  var location = street + "<br>" + city + " &nbsp;" + state + " &nbsp;" + country;
 
  return "<th scope='row' class='dataCell'><a href='/"+ obj.get("Id") +"?srPos=0&amp;srKp=00Q' target='_parent'>"+ obj.get("Name") +"</td>" +
    "<td class='dataCell'>" + phone + "</td>" +
    "<td class='dataCell'>" + location + "</td>" +
    "<td class='dataCell'>" + type + "</td>" +
    "</tr>";
}
</script>

<script id="submitSearch()">
function submitSearch() {
   // alert("inside search");
    var searchMessage = "<center><br><table width=100%>"+
    "<tr><td align=center><span class=moduleTitle>"+
    "<font face=arial>Searching...Please Wait</font></span></td></tr>"+
    "<tr><td>&nbsp;</td></tr><tr><td align=center>"+
    "</td></tr></table></center>";
    document.getElementById("SearchingMessage").innerHTML = searchMessage;
  setTimeout("submitSearch2()",30);
}
function submitSearch2() {
  // beta code -- remove it!   sforceClient.init("{!API.Session_ID}", "{!API.Partner_Server_URL_60}");

  var fullSearchString = getSearchCriteria();
  if (fullSearchString == null) {
    return;
  }

  var records = searchTable(fullSearchString).getArray("searchRecords");
  document.getElementById("SearchingMessage").style.display = 'none';
  var leadListOutput = null;
  var contactListOutput = null;
  var accountListOutput = null;
  var haveLeadList = false;
  var haveContactList = false;
  var haveAccountList = false;

  if (records.length > 0) {
    /* If there were Leads Returned Write them to the screen in the related list format */
    for (var j = 0; j < records.length; j++) {
      var obj = records[j].record;
      if (obj.type == "Lead")
      {
        if (haveLeadList === false)
          leadListOutput = makeLeadListHolder();
        haveLeadList = true;
        leadListOutput += makeLeadRow(obj);
      }
      else if (obj.type == "Contact")
      {
        if (haveContactList === false)
          contactListOutput = makeContactListHolder();
        haveContactList = true;
        contactListOutput += makeContactRow(obj);
      }
      else if (obj.type == "Account")
      {
        if (haveAccountList === false)
          accountListOutput = makeAccountListHolder();
        haveAccountList = true;
        accountListOutput += makeAccountRow(obj);
      }
    }
  }

  /* Finish the Table */
  if (haveLeadList === true) {

    leadListOutput += makeRowFooter("Lead");
  } else {
    leadListOutput = makeEmptyList("Lead");
  }
  if (haveContactList === true) {
    contactListOutput += makeRowFooter("Contact");
  } else {
    contactListOutput = makeEmptyList("Contact");
  }
  if (haveAccountList === true) {
    accountListOutput += makeRowFooter("Account");
  } else {
    accountListOutput = makeEmptyList("Account");
  }

    document.getElementById("LeadsHolder").innerHTML = leadListOutput;
    document.getElementById("ContactsHolder").innerHTML = contactListOutput;
    document.getElementById("AccountsHolder").innerHTML = accountListOutput;
}
</script>

<script id="makeEmptyList(type)">
function makeEmptyList(type) {
  return "</tbody></table></div><div class='pbBody'><table class='list' border='0' cellpadding='0' cellspacing='0'><tbody><tr class='headerRow'><th scope='col' class=''>" +
    "No Matching " + type + "s Found" +
    "</th></tr><tr><td class='pbButton'>" +
    "<input value=' Create New " + type + " ' class='btn' tabindex='100' " +
    "title='Create New " + type + "' type='button' " +
    "name='create" + type + "' method='POST' " +
    "onclick='javascript&colon;create" + type + "Record();'>" +
    "<div class='errorMsg' id='error_General'></div></TD></tr>";
}
</script>

<script id="makeRowFooter()">
function makeRowFooter(type) {
  return "</tbody></table></div><div class='pbBody'><table class='list' border='0' cellpadding='0' cellspacing='0'><tbody><tr><td class='pbButton'>" +
    "<input value=' Create New " + type + " ' class='btn' tabindex='100' " +
    "title='Create New " + type + "' type='button' " +
    "name='create" + type + "' method='POST' " +
    "onclick='javascript&colon;create" + type + "Record();'>" +
    "<div class='errorMsg' id='error_General'></div></TD></tr>";
}
</script>

<script id="getAccountName(accountId)">
function getAccountName(accountId) {
  return sforce.connection.retrieve("Name", "Account", [accountId])[0].get("Name");
}
</script>

RFLRFL
2nd part:


<script id="createAccountRecord()">
function createAccountRecord() {
  //The fields we can use are company and phone
  var phone = document.getElementById("phone").value;
  var company = document.getElementById("company").value;
  var street = document.getElementById("street").value;
  var city = document.getElementById("city").value;
  var country = document.getElementById("country").value;

  var urlParams = "/001/e?retURL=%2F001%2Fo&rt=Account&cancelURL=%2F001%2Fo&nooverride=1";
  if (phone.length > 0) urlParams += "&acc10=" + phone;
  if (company.length > 0) urlParams += "&acc2=" + company;
  if (street.length > 0) urlParams += "&acc17street=" + street;
  if (city.length > 0) urlParams += "&acc17city=" + city;
  if (country.length > 0) urlParams += "&acc17country=" + country;
  window.parent.location.href = urlParams;
}
</script>

<script id="createContactRecord()">
function createContactRecord() {
  //The fields we can use are first name, last name, phone and email
  // get the &conNN values from the html source after clicking "Create New Contact"
  var firstName = document.getElementById("first_name").value;
  var lastName = document.getElementById("last_name").value;
  var phone = document.getElementById("phone").value;
  var email = document.getElementById("email").value;
  var street = document.getElementById("street").value;
  var city = document.getElementById("city").value;
  var country = document.getElementById("country").value;

  var urlParams = "/003/e?retURL=%2F003%2Fo&rt=Contact&cancelURL=%2F003%2Fo&nooverride=1";
  if (firstName.length > 0)
    urlParams += "&name_firstcon2=" + firstName;
  if (lastName.length > 0)
    urlParams += "&name_lastcon2=" + lastName;
  if (phone.length > 0)
    urlParams += "&con10=" + phone;
  if (email.length > 0)
    urlParams += "&con15=" + email;
  if (street.length > 0) urlParams += "&con19street=" + street;
  if (city.length > 0) urlParams += "&con19city=" + city;
  if (country.length > 0) urlParams += "&con19country=" + country;
  window.parent.location.href = urlParams;
}
</script>

<script id="createLeadRecord()">
function createLeadRecord() {
  //The fields we can use are first name, last name, phone, company and email
  var firstName = document.getElementById("first_name").value;
  var lastName = document.getElementById("last_name").value;
  var phone = document.getElementById("phone").value;
  var email = document.getElementById("email").value;
  var company = document.getElementById("company").value;
  var street = document.getElementById("street").value;
  var city = document.getElementById("city").value;
  var country = document.getElementById("country").value;

  var urlParams = "/00Q/e?retURL=%2F00Q%2Fo&rt=Lead&cancelURL=%2F00Q%2Fo&nooverride=1";
  if (firstName.length > 0) {
    urlParams += "&name_firstlea2=" + firstName;
  }
  if (lastName.length > 0) {
    urlParams += "&name_lastlea2=" + lastName;
  }
  if (phone.length > 0) {
    urlParams += "&lea8=" + phone;
  }
  if (email.length > 0) {
    urlParams += "&lea11=" + email;
  }
  if (company.length > 0) {
    urlParams += "&lea3=" + company;
  }
  if (street.length > 0) urlParams += "&lea16street=" + street;
  if (city.length > 0) urlParams += "&lea16city=" + city;
  if (country.length > 0) urlParams += "&lea16country=" + country;
  window.parent.location.href = urlParams;
}
</script>

</head>
<body class="account overviewPage">

<form name="search" id="sprsearch">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="oRight"><a name="skiplink"><img src="/s.gif" height='1' width='1' alt="Content Starts Here" class="skiplink"></a>
    <div class="bPageTitle"><div class="ptBody secondaryPalette"><div class="content">
      <img src="/s.gif" alt="Case" class="pageTitleIcon">
      <h1 class="pageType ">Account / Contact / Lead<span class="titleSeparatingColon">:</span></h1>
      <h2 class="pageDescription">Search &amp; Create</h2><div class="blank">&nbsp;</div></div></div>
      <br>Enter search criteria below in as many fields as possible, all are optional. <br>If no matching pre-existing Account/Contact/Lead is found and you wish to create a new record then the entered fields will be used to create it.
    </div>
    <div class="listing"><div class="bPageBlock secondaryPalette"><div class="pbHeader"></div>
      <div class="pbBody" id="main" name="main"><div class="errorMsg" id="logDiv"></div>
      <!-- all happens here -->
      <table cellspacing="0" cellpadding="0" border="0" class="detailList"><tbody>
        <tr>
          <td class="labelCol"><span class="requiredMark">*</span><label for="first_name">First Name</label></td>
          <td class="dataCol requiredInput">
            <div class="requiredInput"><input maxlength="40" type="text" id="first_name" size="20" name="first_name">
          </td>
          <td class="labelCol"><span class="requiredMark">*</span><label for="company">Company Name</label></td>
          <td class="dataCol requiredInput">
            <div class="requiredInput"><input maxlength="40" type="text" id="company" size="20" name="company"><br>
          </td>
        </tr>
        <tr>
          <td class="labelCol"><span class="requiredMark">*</span><label for="last_name">Last Name</label></td>
          <td class="dataCol requiredInput">
            <div class="requiredInput"><input maxlength="40" type="text" id="last_name" size="20" name="last_name"><br>
          </td>
          <td class="labelCol"><span class="requiredMark">*</span><label for="street">Street Address</label></td>
          <td class="dataCol requiredInput">
            <div class="requiredInput"><input maxlength="40" type="text" id="street" size="20" name="street"><br>
          </td>
        </tr>
        <tr>
          <td class="labelCol"><span class="requiredMark">*</span>Phone</label></td>
          <td class="dataCol requiredInput">
            <div class="requiredInput"><input maxlength="80" type="text" id="phone" size="20" name="phone"><br>
          </td>
          <td class="labelCol"><span class="requiredMark">*</span><label for="city">City</label></td>
          <td class="dataCol requiredInput">
            <div class="requiredInput"><input maxlength="40" type="text" id="city" size="20" name="city"><br>
          </td>
        </tr>
        <tr>
          <td class="labelCol"><span class="requiredMark">*</span>Email</label></td>
          <td class="dataCol requiredInput">
            <div class="requiredInput"><input maxlength="80" type="text" id="email" size="20" name="email"><br>
          </td>
          <td class="labelCol"><span class="requiredMark">*</span><label for="country">Country</label></td>
          <td class="dataCol requiredInput">
            <div class="requiredInput"><input maxlength="40" type="text" id="country" size="20" name="country"><br>
          </td>
        </tr>

        <tr>
          <td class="pbTitle"><img src="/s.gif" alt="" title="" width=1 height=1 class="minWidth"></td>
          <td class="pbButton">
            <input value=" Search First " class="btn" tabindex="100" title="Search" type="button" name="save" method="POST" onclick="javascript:submitSearch();">
            <div class=errorMsg id="error_General"></div>
          </td>
        </tr>

        <tr>
          <!-- td -->
          <!--  ??? -->
          <table cellpadding="0" cellspacing="0" width="100%"><tbody>
              <tr><td class="moduleTitle"></td></tr>
              <tr height="1"><td class="blackLine" height="1"><img alt="" src="/s.gif"></td></tr>
              <tr><td height="10"></td></tr></tbody>
          </table>
          <table cellpadding="0" cellspacing="0" width="100%"><tbody>
              <tr><td class="moduleTitle"></td></tr>
              <tr height="1"><td class="blackLine" height="1"><img alt="" src="/s.gif"></td></tr>
              <tr><td height="10"></td></tr></tbody>
          </table>
          <table cellpadding="0" cellspacing="0" width="100%"><tbody>
              <tr><td class="moduleTitle"></td></tr>
              <tr height="1"><td class="blackLine" height="1"><img alt="" src="/s.gif"></td></tr>
              <tr><td height="10"></td></tr></tbody>
          </table>
         
          <span><div id="SearchingMessage"></div></span>
          <span><div id="AccountsHolder"></div></span>
          <span><div id="ContactsHolder"></div></span>
          <span><div id="LeadsHolder"></div></span>

          <table cellpadding="0" cellspacing="0" width="100%"><tbody>
              <tr><td class="moduleTitle"></td></tr>
              <tr height="1"><td class="blackLine" height="1"><img alt="" src="/s.gif"></td></tr>
              <tr><td height="10"></td></tr></tbody>
          </table>

            <div class=errorMsg id="errorMemberType"></div>
          </div>
          </td>
        </tr>

        </div>
        </td>
        </tr>
        <tr>
          <td>
          <div class="" id="progressDiv"></div>
          </td>
        </tr>
      </tbody>
    </table>
    </div>
    <div class="pbFooter secondaryPalette">
    <div class="bg"></div>
    </div>

    </div>
    </div>

    </td>
  </tr>
</table>
</form>
</body>
</html>
GrayGray

Hi,

I am new to development and coding, but would like to use the code you have re-written for the record de-dup application. Where, in Salesforce, do I put this code to make it work for our organization?

Thanks for your help.

 

Greg RohmanGreg Rohman
Hello.

Our organization has Leads setup as Private. Will this s-control operate outside the security settings of my organization and find all Leads, or will it only find those Leads that the user doing the search has access to? Ideally, we WANT them to be able to search for duplicates... just not allow them to see the detailed information on them.

Thanks in advance.

-Greg
SalesForce De-duplicationSalesForce De-duplication

I do Mass List upload de-duplication, New Lead de-duplication, Web to Lead de-duplication, and Data Cleansing. We are a SalesForce App Exchange Partner shoot me a message if you want to chat about the product or you can email me at nmaloney@stratagemsales.com.