How to have different contact address fields depending on the country selected?

You must create different address fields using address formats depending on the country you selected.

To create an address style format:

  • Specify the address style format and address style

  • Create the format variation layout

  • Assign a locale

In this example, we will create an address style to format Canadian postal addresses.

Create the Address Style Format Name and Specify the Address Style

To create an address style format and specify the address style:

  1. In the Setup and Maintenance work area, go to the following:

    • Offering: Customer Data Management

    • Functional Area: Trading Community Foundation

    • Task: Manage Address Formats

  2. On the Manage Address Formats page, click Create from the actions menu.

  3. On the Create Address Style Format page, complete the fields in the Overview section, as shown in the following table.

    Field

    Value

    Code

    CA_POSTAL_ADDR

    Name

    Canadian Postal Address Format

    Address Style

    Postal Address

    Default

    No

  4. Click Save.

Create the Format Variation Layout

To create a format variation layout:

  1. In the Format section on the Create Address Style Format page, click the Format Layout tab.

  2. In the Format Variation section, select Add from the Actions menu.

  3. Enter a variation rank in the Variation field.

    Note: You can't change the Variation Number. If you're specifying Create and Edit address forms, always use variation value as 1 irrespective of rank. If you're specifying Read Only formatted address (either single line or more than one line), always use variation with highest rank.
  4. In the Format Variation Layout section, select Add from the Action menu.

  5. Complete the fields as shown in the following table.

    Field

    Value

    Line

    1

    Position

    1

    Prompt

    Address line 1

    Address Element

    Address line 1

    Required

    Yes

    Uppercase

    No

  6. Create another address line as shown in the following table.

    Field

    Value

    Line

    2

    Position

    2

    Prompt

    City

    Address Element

    City

    Required

    Yes

    Uppercase

    Yes

  7. Click Expand on the City address line, then enter the value 1 in Blank Lines Before.

  8. You can create as many address lines as you require. Click Expand if you want to enter blank lines and delimiters before, or after, an address line. In this section, you can also use the Attribute Transform Function to specify how the country attribute value must be displayed. The Attribute Transform Function supports two functions:

    • hz_format_pub.get_tl_territory_name(COUNTRY)

    • hz_format_pub.get_neu_country_code(COUNTRY)

    These functions are used only in display formats or read-only formats where the address data is formatted in a single field. Examples for such formats are overview pages and multiple addresses section in a list. Let's look at these functions in detail:

    • hz_format_pub.get_tl_territory_name(COUNTRY): Converts a country code of a country into its name. For example, MX is converted to Mexico. The country is displayed in the language that's set in the user profile. If the profile value of the ORA_HZ_INCLUDE_REGIONAL_COUNTRY profile option is set to yes and the country name set in the user profile is the same as the country attribute value, then the country name is displayed. If the profile value of the ORA_HZ_INCLUDE_REGIONAL_COUNTRY profile option is set to no and the country name set in the user profile is the same as the country attribute value, the country name isn't displayed. To change the profile value, navigate to the following in the Setup and Maintenance work area:

      • Offering: Sales

      • Functional Area: Sales Foundation

      • Task: Manage Administrator Profile Values

    • hz_format_pub.get_neu_country_code(COUNTRY): Converts a country code for North European countries into a code that's placed before the postal code in a formatted address. For example, for France F is placed before the postal code. B is used for Belgium, D for Germany, and so on.

      Note: For more information about territory codes and their prefix for North European postal codes, see Seeded Address Formats for Countries topic.
    Note: While creating a new address style format, make sure that the transform function is present for each component as in predefined address style formats. The transform function may impact translation.

Assign a Locale

An address style format is assigned to a geographic location. Locale provides mapping between territory_code and address style format.

To assign an address style format to a locale:

  1. In the Format section on the Create Address Style Format page, click the Locale Assignment tab.

  2. Select New from the Actions menu.

  3. Select the country for the address style format. You can assign multiple countries to the format.

  4. Click Save and Close.