Phone Number Format

SOLVED

Is there a way to set the format for phone numbers?

Each sales person has a different way to enter customer and so we end up writing spaces, dashes, parentheses, etc in the AR_Customer table.

I would like to set a format so that all phone numbers look the same no matter who inputs them.

A second part of this would be international number??? Can that be do as well?

Thanks,

  • 0

    enter the number with no formatting, no spaces, dashes or parentheses and the system will correctly format. With international you have to manually enter.

  • +1
    verified answer

    Carrot and a Stick?

    If you were just dealing with US numbers, when you enter a value that is exactly 10 digits (with any number of spaces), Sage 100 will automatically format it like "(888) 888-8888".  This is ends up taking up 14 of the 20 characters allowed.

    However, if you enter any other characters besides digits, such as a dash or parenthesis, Sage 100 will not format it.

    Here is a very simple script that can be assigned to the AR_Customer table's pre-validate event for the TelephoneNo column.  This script simply removes any character that is not a digit so Sage 100 will automatically format it.  If you want to format international numbers, you will have to handle that yourself.  It will also set an error if the number of digits entered is less than 10.  This can all be tweaked.

    sTelephoneNo = "" : oBusObj.GetValue "TelephoneNo$", sTelephoneNo
    sPatternToReplace = "\D"
    Set oRegExp = New RegExp
    oRegExp.IgnoreCase = True
    oRegExp.Global = True
    oRegExp.Pattern = sPatternToReplace
    sTelephoneNo = oRegExp.Replace(sTelephoneNo, "")
    Set oRegExp = Nothing
    If Len(sTelephoneNo) < 10 Then
    	oScript.SetError """" & sTelephoneNo & """ is not a valid telephone number.  It must be at least 10 digits long."
    Else
    	oScript.DeactivateProcedure "*"
    	oBusObj.SetValue "TelephoneNo$", sTelephoneNo
    	oScript.ActivateProcedure "*"
    End If

  • 0 in reply to David Speck

    That is a nice script David... fun with regular expressions!

    You could probably do a simple country check (and only run the validation & reformatting for USA / Canada / ...).

  • 0 in reply to Kevin M

    How can I integrate that country check in the script David wrote?

  • 0 in reply to Kevin M

    Checking the country is a good idea.

    I threw this together in 5 minutes but i don't deal enough with international numbers to know standard formatting. 

    Could always combine the country check with some string manipulation like Left and Mid to add characters like (, ), +, -, etc where they are needed after getting just the digits like i did with the regex expression.

  • +1 in reply to Hugo Rojas
    verified answer

    To simply exit early, something like this should work right at the top of his script.

    sCountryCode = "" : oBusObj.GetValue "CountryCode$", sCountryCode 
    if sCountryCode <> "USA" and sCountryCode <> "US" and sCountryCode <> "CAN" and sCountryCode <> "CA" then
    	exit sub
    end if

  • 0 in reply to David Speck

    Indeed.  Me neither.  Skipping non-NA country codes is a cheap fix, but for specific country codes someone could run customized validation based on what the normal convention is.

  • 0 in reply to Kevin M

    That worked perfectly. Thank you so much.

    I'm pretty new to using SAGE but have been learning tons from all these blogs.