Show / Hide Table of Contents

Class PhoneFormatter

Functions for formatting a person's or contact's phone number.

Inheritance
Object
PhoneFormatter
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: SuperOffice.CRM.Globalization
Assembly: SoDataBase.dll
Syntax
public static class PhoneFormatter
Remarks

It is HIGHLY recommended that all phone numbers entered by the users in the user interface are formatted with the before saving them to the database.

It is recommended that online clients use GetLongDisplayNumber(Int32, String) with 'false' for the 'includeDialOutNumber' option - unless one assumes a usage pattern where users are mostly in the same country as their currently defined 'home country' (the case for mostly stationary users, as opposed to internationally travelling users)

It is recommended that windows clients use GetShortDisplayNumber(Int32, String) with 'false' for the 'includeDialOutNumber' option. This assumes that such users are generally in their home country.

Methods

CleanNumber(String)

Get all the digits from the phone number.

Declaration
public static string CleanNumber(string phone)
Parameters
Type Name Description
String phone

Phone number that may contain alphabetical letters: "1-800-PizzaNow"

Returns
Type Description
String

Digits only: "1-800-84992789"

FormatNumberForDatabase(Int32, Int32, String)

Remove unnecessary prefix on phone number and make it compliant to the database format.

Declaration
public static string FormatNumberForDatabase(int fromCountryId, int toCountryId, string phone)
Parameters
Type Name Description
Int32 fromCountryId

CountryId of the logged on user.

Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as entered by the user in the user interface.

Returns
Type Description
String

Phonenumber where unnecessary prefix is removed.

Remarks

If the phone number is in the same country as the person or contact, the country prefix is removed.

See Also
IsInterAreaPrefixClassic

FormatNumberForDatabase(Int32, String)

Remove unnecessary prefix on phone number and make it compliant to the database format.

Declaration
public static string FormatNumberForDatabase(int toCountryId, string phone)
Parameters
Type Name Description
Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as entered by the user in the user interface.

Returns
Type Description
String

Phonenumber where unnecessary prefix is removed.

Remarks

If the phone number is in the same country as the person or contact, the country prefix is removed.

GetBaseNumber(Int32, Int32, String)

Get the phone number formatted as if to be dialed from a normal house phone. Add internation dial prefix as necessary.

Declaration
public static string GetBaseNumber(int fromCountryId, int toCountryId, string phone)
Parameters
Type Name Description
Int32 fromCountryId

CountryId of the logged on user.

Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as entered by the user in the user interface.

Returns
Type Description
String

Phone number formatted as if to be dialed from a normal house phone.

GetBaseNumber(Int32, String)

Get the phone number formatted as if to be dialed from a normal house phone. Add international dial prefix as necessary.
Assumes dialing from current user's home country.

Declaration
public static string GetBaseNumber(int toCountryId, string phone)
Parameters
Type Name Description
Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as entered by the user in the user interface.

Returns
Type Description
String

Phone number formatted as if to be dialed from a normal house phone.

GetEntityElementStrippedValue(Int32, String)

Get the phone number as formatted according to the NetServer service layer inteded for machines.

Declaration
public static string GetEntityElementStrippedValue(int toCountryId, string phone)
Parameters
Type Name Description
Int32 toCountryId

CountryId of the logged on user.

String phone

Phone number as entered by the user in the user interface.

Returns
Type Description
String

Number according to the service layer of NetServer.

Remarks

The AllwaysUseGsmPhoneStyle is observed.

GetEntityElementValue(Int32, String)

Get the phone number as formatted according to the NetServer service layer inteded for UI.

Declaration
public static string GetEntityElementValue(int toCountryId, string phone)
Parameters
Type Name Description
Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as entered by the user in the user interface.

Returns
Type Description
String

Number according to the service layer of NetServer.

Remarks

The AllwaysUseGsmPhoneStyle is observed.

GetGSMNumber(Int32, String)

Get the phone number in a GSM compliant format.

Declaration
public static string GetGSMNumber(int toCountryId, string phone)
Parameters
Type Name Description
Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as read from the database.

Returns
Type Description
String

Phone number in a GSM compliant format. ("+4712345678")

Remarks

The phone number is formated according to the GSM standard for phone numbers. This means [+] + [countrycode] + [national number].
Letters in the phone numbers are resolved.

GetInternationalNumber(Int32, String)

Get the international phone number.

Declaration
public static string GetInternationalNumber(int toCountryId, string phone)
Parameters
Type Name Description
Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as entered by the user in the user interface.

Returns
Type Description
String
Remarks

The phone number is formated according to certain broadband and international calling card systems where country prefix always need to be present.
This means [countrycode] + [national number]. Letters in the phone numbers are resolved.

GetLongDisplayNumber(Int32, Int32, String)

Get the long display format for the for the number, including country and areacode.

Declaration
public static string GetLongDisplayNumber(int fromCountryId, int toCountryId, string phone)
Parameters
Type Name Description
Int32 fromCountryId

CountryId of the logged on user.

Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as entered by the user in the user interface.

Returns
Type Description
String

Long display format for the for the number.

Remarks

Numbers part of the american phone system will not get the areacode.

GetLongDisplayNumber(Int32, Int32, String, Boolean)

Get the long display format for the for the number, including country and areacode.

Declaration
public static string GetLongDisplayNumber(int fromCountryId, int toCountryId, string phone, bool includeDialOutNumber)
Parameters
Type Name Description
Int32 fromCountryId

CountryId of the logged on user.

Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as entered by the user in the user interface.

Boolean includeDialOutNumber

Include the number to dial out, false will use '+'

Returns
Type Description
String

Long display format for the for the number.

Remarks

Numbers part of the american phone system will not get the areacode.

GetLongDisplayNumber(Int32, Int32, String, Boolean, Boolean, Boolean)

Get the long display format for the for the number, including country and areacode.

Declaration
public static string GetLongDisplayNumber(int fromCountryId, int toCountryId, string phone, bool includeDialOutNumber, bool allwaysUseGsmPhoneStyle, bool removeDialInterArea)
Parameters
Type Name Description
Int32 fromCountryId

CountryId of the logged on user.

Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as entered by the user in the user interface.

Boolean includeDialOutNumber

Include the number to dial out, false will use '+'

Boolean allwaysUseGsmPhoneStyle

Force the phone number to displayed compatible with GSM phones (+ [CountryCode] - no inter area)

Boolean removeDialInterArea
Returns
Type Description
String

Long display format for the for the number.

Remarks

Numbers part of the american phone system will not get the areacode.

GetLongDisplayNumber(Int32, String)

Get the long display format for the for the number, including country and areacode.

Declaration
public static string GetLongDisplayNumber(int toCountryId, string phone)
Parameters
Type Name Description
Int32 toCountryId

CountryId of the logged on user.

String phone

Phone number as entered by the user in the user interface.

Returns
Type Description
String

Long display format for the for the number.

Remarks

Numbers part of the american phone system will not get the areacode.

GetPrefix(Int32)

Get the prefix used in edit boxes entered before the user types the phone number.

Declaration
public static string GetPrefix(int toCountryId)
Parameters
Type Name Description
Int32 toCountryId

Country to dial to. (578=norway)

Returns
Type Description
String

The prefix including leading "+" (e.g. "+47" for norway)

GetShortDisplayNumber(Int32, Int32, String)

Get the short display format for the for the number, including areacode.

Declaration
public static string GetShortDisplayNumber(int fromCountryId, int toCountryId, string phone)
Parameters
Type Name Description
Int32 fromCountryId

CountryId of the logged on user.

Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as entered by the user in the user interface.

Returns
Type Description
String

Long display format for the for the number.

Remarks

This is the same as GetLongDisplayNumber(Int32, String) if from country and to country is not the same.
Numbers part of the american phone system will not get the areacode.

GetShortDisplayNumber(Int32, Int32, String, Boolean)

Get the short display format for the for the number, including areacode.

Declaration
public static string GetShortDisplayNumber(int fromCountryId, int toCountryId, string phone, bool includeDialOutNumber)
Parameters
Type Name Description
Int32 fromCountryId

CountryId of the logged on user.

Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as entered by the user in the user interface.

Boolean includeDialOutNumber

Include the number to dial out, false will use '+'

Returns
Type Description
String

Long display format for the for the number.

Remarks

This is the same as GetLongDisplayNumber(Int32, String) if from country and to country is not the same.
Numbers part of the american phone system will not get the areacode.

GetShortDisplayNumber(Int32, Int32, String, Boolean, Boolean)

Get the short display format for the for the number, including areacode.

Declaration
public static string GetShortDisplayNumber(int fromCountryId, int toCountryId, string phone, bool includeDialOutNumber, bool allwaysUseGsmPhoneStyle)
Parameters
Type Name Description
Int32 fromCountryId

CountryId of the logged on user.

Int32 toCountryId

CountryId of the person or contact owning the phone number.

String phone

Phone number as entered by the user in the user interface.

Boolean includeDialOutNumber

Include the number to dial out, false will use '+'

Boolean allwaysUseGsmPhoneStyle

Force the phone number to displayed compatible with GSM phones (+ [CountryCode] - no inter area)

Returns
Type Description
String

Long display format for the for the number.

Remarks

This is the same as GetLongDisplayNumber(Int32, String) if from country and to country is not the same.
Numbers part of the american phone system will not get the areacode.

GetShortDisplayNumber(Int32, String)

Get the short display format for the for the number, including areacode.

Declaration
public static string GetShortDisplayNumber(int toCountryId, string phone)
Parameters
Type Name Description
Int32 toCountryId

CountryId of the logged on user.

String phone

Phone number as entered by the user in the user interface.

Returns
Type Description
String

Long display format for the for the number.

Remarks

This is the same as GetLongDisplayNumber(Int32, String) if from country and to country is not the same.
Numbers part of the american phone system will not get the areacode.

ResolveAlphanumericNumber(String)

Resolve alphanumeric numbers (i.e. 'A', 'B' or 'C' resolves to '2')

Declaration
public static string ResolveAlphanumericNumber(string phone)
Parameters
Type Name Description
String phone

Phone number that can contain alphanumeric letters.

Returns
Type Description
String

Phone number with only numbers and possibly a '+' prefix.

© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top