- Normalize phone numbers in CRM?
- Posted by sketchy on March 2nd, 2007
Curious to know what other do for CRM user's who aren't very good at
following directions on how to enter phone numbers as we require. We would
like them to use parenthasis around the area code, but sometimes they don't
do it. Do any of you use some T-SQL routines or anything to correct the
entries on an incremental basis? ...Or is there a better way to handle it?
--
Sketchy
- Posted by iqueue on March 2nd, 2007
"sketchy" wrote:
I've found that the best way to deal with this situation is javascript tied
to the onchange event of the actual field (FAX e.g.).
// If the number has a valid length, format the number.
switch (sTmp.length)
{
case "4105551212".length:
oField.DataValue = sTmp.substr(0, 3) +"-"+ sTmp.substr(3, 3) + "-"
+ sTmp.substr(6, 4);
break;
case "5551212".length:
oField.DataValue = sTmp.substr(0, 3) + "-" + sTmp.substr(3, 4);
break;
}
}
The code would be different for your case - because you'd like parentheses
around the numbers but this is the general idea.
I'm not sure about modifying the T-SQL - and I'd try to stay away from doing
this.
Best of Luck to you.
- Posted by Bob Potter on March 5th, 2007
When I put this script in, I get a error, "sTmp is undefined". Probably due
to my lack of scripting knowledge. Any advice? :-)
Thanks!
Bobotron
On 3/2/07 9:20 AM, in article
BED1C9EA-6EBA-4755-896F-F350FC14A7E5@microsoft.com, "iqueue"
<iqueue@discussions.microsoft.com> wrote:
- Posted by iqueue on March 5th, 2007
Bobotron,
Yeah - you need to declare the variable.
Here's some code that preceeded the code below (or above from the user's
perspective).
// Get the field that fired the event.
var oField = event.srcElement;
// Validate the field information.
if (typeof(oField) != "undefined" && oField != null)
{
// Remove any nonnumeric characters.
var sTmp = oField.DataValue.replace(/[^0-9]/g, "");
"Bob Potter" wrote:
- Posted by Bob Potter on March 5th, 2007
That works. Thanks for helping the noob.
On 3/5/07 10:02 AM, in article
501CBC2A-BD00-4624-831D-940D98BC2C8A@microsoft.com, "iqueue"
<iqueue@discussions.microsoft.com> wrote:
- Posted by Voni on March 21st, 2007
Hi,
I am new at javascripting also. I need the parenthesis in the phone number
and tried changing the script to the following. I did something incorrect
though...when I save the record and look at it again, the phone number format
hasn't changed at all......could you (please?) tell me what I did wrong?
oField.DataValue = "(" + sTmp.substr(0, 3) + ")" + " " + sTmp.substr(3, 4);
break;
Thank you!
Voni
"Bob Potter" wrote:
- Posted by Voni on March 21st, 2007
sorry....put the wrong line in..here is the code I used...
oField.DataValue = "( " + sTmp.substr(0, 3) +") "+ " "+ sTmp.substr(3, 3) +
"-"
+ sTmp.substr(6, 4);
"Voni" wrote:
- Posted by Voni on March 21st, 2007
hmmmm.....must have been a spacing issue or something...it works now!
"Voni" wrote: