Ever wanted to get some more "fuzziness" in your detection rules? Then Soundex as a phonetic algorithm will be your friend. There are some caveats but for some applications it might be useful. The nice thing is, that it's super-easy to implement.
Let's consider two options (in your project you might want to go for a "best of both worlds" approach by using both):
Method1 Clientside: Generating the Soundex-Code at the onSave event
Pro: Quick and easy implementation
Con: Will not work on imports or Bulk Operations
Step by step:
1) add a custom field "new_soundex_lastname" to the desired entity (lead, account, contact or any custom entity)
2) add the field to the form
3) add this onSave event:
function soundex(str) {
// original from http://phpjs.org/functions/soundex:520
var i, j, l, r, p = isNaN(p) ? 4 : p > 10 ? 10 : p < 4 ? 4 : p;
var m = {BFPV: 1, CGJKQSXZ: 2, DT: 3, L: 4, MN: 5, R: 6};
var r = (s = (str+'').toUpperCase().replace(/[^A-Z]/g, "").split("")).splice(0, 1);
var sl = 0;
sl = s.length;
for (i = -1, l = sl; ++i < l;) {
for (j in m) {
if (j.indexOf(s[i]) + 1 && r[r.length-1] != m[j] && r.push(m[j])) {
break;
}
}
}
return r.length > p && (r.length = p), r.join("") + (new Array(p - r.length + 1)).join("0");
}
crmForm.all.new_soundex_lastname.DataValue=soundex(crmForm.all.lastname.DataValue);
4) add a duplicate rule & publish
5) enjoy life without unneccessary duplicates ;-)
Method 2 Plugin: Firing at Pre-Create event
Pro: Works on Imports
Con: A bit more work
0 komentar:
Posting Komentar