FORMAT(); Used for Phone Numbers?
Xypher
Member Posts: 297
Anyone know if I can use FORMAT() function to display 10+ digits as:
(XXX)XXX-XXXX or XXX-XXX-XXXX ?
(I have just started working in NAV two weeks ago, so I am still learning. I tried looking up all the information I could find on FORMAT but could not identify whether or not I would be able to complete this task.)
(XXX)XXX-XXXX or XXX-XXX-XXXX ?
(I have just started working in NAV two weeks ago, so I am still learning. I tried looking up all the information I could find on FORMAT but could not identify whether or not I would be able to complete this task.)
0
Answers
-
Hello There is no format function for phone no.
I usually add this codePhone No. - OnValidate() //T01 Start IF GUIALLOWED AND (CurrFieldNo = FIELDNO("Phone No.")) THEN BEGIN IF STRLEN("Phone No.") < 10 THEN ERROR('Please Enter at least 10 Digit number'); END; IF ("Phone No." <> '') AND (STRLEN("Phone No.") >= 10) THEN BEGIN TempStr := ''; FOR I := 1 TO STRLEN("Phone No.") DO BEGIN IF EVALUATE(TempInt,FORMAT("Phone No."[I])) THEN TempStr += FORMAT("Phone No."[I]); END; IF GUIALLOWED AND (CurrFieldNo = FIELDNO("Phone No.")) THEN BEGIN IF NOT (STRLEN(TempStr) IN [10,12,13]) THEN ERROR('Please Enter 10 or 12 or 13 Digit number'); END; IF STRLEN(TempStr) = 10 THEN "Phone No." := '(' + COPYSTR(TempStr,1,3) + ')-' + COPYSTR(TempStr,4,3) + '-'+COPYSTR(TempStr,7); IF STRLEN(TempStr) = 13 THEN "Phone No." := COPYSTR(TempStr,1,3) + '-' + COPYSTR(TempStr,4,3) + '-'+ COPYSTR(TempStr,7,3) + COPYSTR(TempStr,10); IF STRLEN(TempStr) = 12 THEN "Phone No." := COPYSTR(TempStr,1,2) + '-' + COPYSTR(TempStr,3,3) + '-'+ COPYSTR(TempStr,6,3) + COPYSTR(TempStr,9); END; //T01 End0 -
The Variable
Name DataType Subtype Length TempStr Text 30 I Integer TempInt Integer
0 -
Thank you for the answer.
Although, no offense, I think I can whip up a little bit cleaner and refined code to do the job.
0 -
Please do and post the code.0
-
Well I suppose not refined or very clean looking...
(Text field set 'AllowChar: 09--')ValidatePhoneNumber(PhoneNumber : Text[30]) : Text[30] IF STRLEN(PhoneNumber) > 0 THEN BEGIN PhoneNumber := DELCHR(PhoneNumber,'=','-'); PhoneNumber := DELCHR(PhoneNumber,'=',' '); IF PhoneNumber[1] = '1' THEN PhoneNumber := COPYSTR(PhoneNumber,2); IF STRLEN(PhoneNumber) < 10 THEN FOR Count := 1 TO (10 - STRLEN(PhoneNumber)) DO PhoneNumber += '?'; PhoneNumber := COPYSTR(PhoneNumber,1,3) + '-' + COPYSTR(PhoneNumber,4,3) + '-' + COPYSTR(PhoneNumber,7); IF STRLEN(PhoneNumber) > 12 THEN PhoneNumber := COPYSTR(PhoneNumber,1,12) + ' ' + COPYSTR(PhoneNumber,13); END; EXIT(PhoneNumber);0 -
Try to call your function with
'(234) 567-8900'0 -
missed that.0
-
btw what company are you working in VA?0
-
SimplyWireless0
-
How are they doing?
Is the replication working for them?
Is Marty still taking care of everything?
I wrote all the code modification for the POS. I'm guessing you've been cleaning that up?0 -
I believe they are doing quite well since they've been buying up quite a bit of stores on the east coast.
Replication still appears to be quite a task for them.
As far as Marty goes, not sure, since I am in an office all by myself I don't see much of what's going on around.
So far I've been working on initial training and small projects, since it was only 3 weeks ago that I first ever heard of NAV.0 -
How many location do they have now? and how big is their db?
Last Time I checked it was reaching 50 gig, and they were trying to setup on SQL 2k5 mirroring and they were running out of space.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 328 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
