phone number format ?

Durand
Member Posts: 61
Hello, I am a young developer end user in an entrepsise which uses Navision (v. FR 2.01). The users wish to have all the fields of phone number in the size(format) "99 99 99 99 99", at the level of tables. What is best method? Thank you.
Benoît Durand
Benoît Durand
0
Comments
-
Assuming that a user will always enter the data as 10 digits with no spaces (goofyfishalthough as we both know, this is not a very valid assumption) you could use the following code:
//>> insert - OnValidate() of field "Phone No."
CLEAR(textNewPhoneFormat);
FOR intX := 1 TO 5 DO BEGIN
textNewPhoneFormat := textNewPhoneFormat + COPYSTR("Phone No.",((intX *2)-1),2);
IF intX < 5 THEN
textNewPhoneFormat := textNewPhoneFormat + ' ';
END;
"Phone No." := textNewPhoneFormat;
//<< end insert
If this formatting is to be used in multiple locations in your application, it would be better to use the code in a Codeunit, and call from the table OnValidate() triggers where needed. I would recommend that you test the field for the appropriate number of digits...
intPhoneNoLength := STRLEN("Phone No.");
IF intPhoneNoLength <> 10 THEN
ERROR('Blah blah blahdee blah');
Or some such test as needed. Hope this helps you, please let me know if there is more I can do for you.
Take Care,
Rick
Rick Acton
NCPS, NCDS, NCHRS, NCFAS
High-Tech Consulting Services
5735 Industry Lane, Bldg A, Ste 9
Frederick, MD 21701-7281
301-662-0732 v
301-662-0836 f0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions