Results 1 to 7 of 7

Thread: How to handle country codes

  1. #1
    ActraiserVII is offline Member
    Join Date
    Apr 2010
    Location
    Downtown Ohio
    Posts
    9

    Default How to handle country codes

    Good day,

    I've searched the forums exhaustively, and have yet to find a solution to what I want to do. I want to find a way to use a dropdown to append a country code to the beginning of the phone number field. I'm completely open to accomplishing this by any means. Whether the dropdown be Javascript, or built with Sugar.

    I'm fairly novice, so any help or input would be appreciated very much.

    Thank you.

    EDIT: Also, I am using Sugar CE 5.5.1 with PHP 5.2.10 and MySQL 5.1.37.
    Last edited by ActraiserVII; 2010-04-27 at 03:09 PM. Reason: Adding details!

  2. #2
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Default Re: How to handle country codes

    Is this dropdown to be automated in any way? If not then just create a dropdown custom field in studio and add a list of codes to it.
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

  3. #3
    ActraiserVII is offline Member
    Join Date
    Apr 2010
    Location
    Downtown Ohio
    Posts
    9

    Default Re: How to handle country codes

    Quote Originally Posted by kbrill View Post
    Is this dropdown to be automated in any way? If not then just create a dropdown custom field in studio and add a list of codes to it.
    I want the dropdown to append a value to the beginning of the phone number field. For example, if I made the dropdown in Studio, I would have a dropdown list where the "display label" would be a country, and the "item name" would be a code. So if I selected Tanzania, it would append 255 to the beginning of what is already in the phone number field. It is important that the country code and the rest of the phone number are kept in the same field.

    Thanks for your response!

  4. #4
    christianknoll's Avatar
    christianknoll is offline Sugar Community Member
    Join Date
    Nov 2008
    Location
    Vienna
    Posts
    939

    Default Re: How to handle country codes

    You will have to create a custom field type. We typically do exactly what you are asking for and have this in our standard template. The whole thing is not very tricky but will require some php skills as well as a decnet understanding on sugarcrm.

    regards, christian.

    Quote Originally Posted by ActraiserVII View Post
    I want the dropdown to append a value to the beginning of the phone number field. For example, if I made the dropdown in Studio, I would have a dropdown list where the "display label" would be a country, and the "item name" would be a code. So if I selected Tanzania, it would append 255 to the beginning of what is already in the phone number field. It is important that the country code and the rest of the phone number are kept in the same field.

    Thanks for your response!

  5. #5
    ActraiserVII is offline Member
    Join Date
    Apr 2010
    Location
    Downtown Ohio
    Posts
    9

    Default Re: How to handle country codes

    Quote Originally Posted by christianknoll View Post
    You will have to create a custom field type. We typically do exactly what you are asking for and have this in our standard template. The whole thing is not very tricky but will require some php skills as well as a decnet understanding on sugarcrm.

    regards, christian.
    Thanks for your response. Are you saying I'll have to create a custom field type for both the dropdown and the phone number field? Or only for one or the other? I assumed I was going to have to use PHP to produce the dropdown. You say "we" and "our standard template", could I have a little more information please?

    Thanks again.

  6. #6
    datasponge is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    San Jose, CA, USA
    Posts
    553

    Default Re: How to handle country codes

    Hi ActraiserVII,

    You could convert the country field to a dropdown and write a before_save logic hook to update the phone numbers.

    See this thread for how to convert the country field to dropdown.

    The logic hook could be simple or complex depending on how much error checking and replacing you want to do. If you keep it simple like:

    1. look for a '+' at the start of phone.
    2. if missing add + and country code
    3. if already a '+', parse to first space and replace old code with new

    After that you can get as fancy as you like formatting and fixing the string, adding area codes, etc, but it starts to get complicated.

    Of course you will need a table or dropdown that lists all the countries and their country code so you can look them up with a query.

    Phil

  7. #7
    ActraiserVII is offline Member
    Join Date
    Apr 2010
    Location
    Downtown Ohio
    Posts
    9

    Default Re: How to handle country codes

    Quote Originally Posted by datasponge View Post
    Hi ActraiserVII,

    You could convert the country field to a dropdown and write a before_save logic hook to update the phone numbers.

    See this thread for how to convert the country field to dropdown.

    The logic hook could be simple or complex depending on how much error checking and replacing you want to do. If you keep it simple like:

    1. look for a '+' at the start of phone.
    2. if missing add + and country code
    3. if already a '+', parse to first space and replace old code with new

    After that you can get as fancy as you like formatting and fixing the string, adding area codes, etc, but it starts to get complicated.

    Of course you will need a table or dropdown that lists all the countries and their country code so you can look them up with a query.

    Phil
    Thanks for your response. I will look into this post. You all have been helpful.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. UK Post Codes
    By salesagility in forum Feature Requests
    Replies: 0
    Last Post: 2010-03-25, 02:25 PM
  2. Magic codes
    By AlainVDS in forum Installation and Upgrade Help
    Replies: 2
    Last Post: 2009-09-22, 07:57 AM
  3. Strange behaviour with custom codes
    By subhajit in forum Developer Help
    Replies: 1
    Last Post: 2009-05-29, 12:45 PM
  4. Replies: 0
    Last Post: 2008-04-04, 12:38 PM
  5. Replies: 0
    Last Post: 2005-12-26, 05:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •