phone number format ?

DurandDurand Member Posts: 61
edited 2001-07-05 in Navision Financials
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

Comments

  • goofyfishgoofyfish Member Posts: 5
    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 f
Sign In or Register to comment.