Resources for IT Professionals > Dynamics Forums > CRM > CRM 4.0 - Customize Address (City) field format
Ask a questionAsk a question
 

AnswerCRM 4.0 - Customize Address (City) field format

  • Thursday, October 01, 2009 8:34 PMRyPhi Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I want to have the City field automatically format (in the Contact and Business entities) to capitalize the first character.
    (i.e. user enters 'scottsdale', system formats 'Scottsdale').

    Any ideas?

Answers

  • Thursday, October 01, 2009 8:56 PMKuba Skalbania Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    Hi,

    Go to "Settings" / "Customization" / "Customize entities" and open the entity you would like to add the attribute to (e.g. Contact in your case). Open "Forms and views" and "Form". On the customization form of the Contact entity, click the City field and go to "Events" tab. Add the OnChange event with the following script (provided that you refer to the "Address 1: City" field when talking about "City". If not, replace the field name):

    var oldCity = crmForm.all.address1_city.DataValue;
    var newCity = oldCity.substring(0,1).toUpperCase() + oldCity.substring.(1,oldCity.length);
    crmForm.all.address1_city.DataValue = newCity;
    
    I hope that helps,
    Kuba
    -- Kuba Skałbania, Netwise
  • Thursday, October 01, 2009 9:00 PMLeon TribeMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Thanks to the Stunnware blog (http://stunnware.com/crm2/topic.aspx?id=JS4) we know how to make a string all capital

    crmForm.all.<name of text field>.DataValue = crmForm.all.<name of text field>.DataValue.toUpperCase();

    Then we have this from Stack Overflow


    which is a jscript function for converting to proper form.

    Hope it helps.

    Leon Tribe
    Want to hear me talk about all things CRM? Check out my blog
    or hear me tweet @leontribe

    Want to hear me talk about all things CRM? Check out my blog http://leontribe.blogspot.com/ or hear me tweet @leontribe

All Replies

  • Thursday, October 01, 2009 8:56 PMKuba Skalbania Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    Hi,

    Go to "Settings" / "Customization" / "Customize entities" and open the entity you would like to add the attribute to (e.g. Contact in your case). Open "Forms and views" and "Form". On the customization form of the Contact entity, click the City field and go to "Events" tab. Add the OnChange event with the following script (provided that you refer to the "Address 1: City" field when talking about "City". If not, replace the field name):

    var oldCity = crmForm.all.address1_city.DataValue;
    var newCity = oldCity.substring(0,1).toUpperCase() + oldCity.substring.(1,oldCity.length);
    crmForm.all.address1_city.DataValue = newCity;
    
    I hope that helps,
    Kuba
    -- Kuba Skałbania, Netwise
  • Thursday, October 01, 2009 9:00 PMLeon TribeMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Thanks to the Stunnware blog (http://stunnware.com/crm2/topic.aspx?id=JS4) we know how to make a string all capital

    crmForm.all.<name of text field>.DataValue = crmForm.all.<name of text field>.DataValue.toUpperCase();

    Then we have this from Stack Overflow


    which is a jscript function for converting to proper form.

    Hope it helps.

    Leon Tribe
    Want to hear me talk about all things CRM? Check out my blog
    or hear me tweet @leontribe

    Want to hear me talk about all things CRM? Check out my blog http://leontribe.blogspot.com/ or hear me tweet @leontribe
  • Wednesday, November 04, 2009 7:52 PMRussell Karp Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thank you for the posting.  I tried out this script but keep getting errors.  Any troubleshooting tips?