Address Fields DropDown

Hello, I read some posts that talk about the possibility of creating the address fields with dropdown tendon.

I have some questions to ask in order to understand how to set up in the best way these fields. I would like to create fields that depart from the State (Italy) and then recall the regions (Abruzzo, Molise, etc.) which in turn recall the provinces (Chieti, Pescara, Teramo, etc.) and which in turn recall the city…

In the current situation, in Studio, I noticed that the address fields are part of a bunched field that you can not manage (I understand that the fields were raggrupati by code).
If you want to disable the default address fields and create other fields with the system dropdown you could do?
And 'it recommended this procedure?
There are alternative methods to get the results that I am looking for?
Thanks for the support

Search in the forum for Dynamic DropDown fields and you will find a few explanations on how to achieve Country (Eg: Italy)->State (Eg: Lombardy)->County (Eg: Milan)->City (Eg: Linate) (I have also posted a similar example)

You should note that you would be creating custom fields and I believe that the actual address fields have some special functionality and code associated to them and these custom fields, unless you customise also the code, will not have the same functionality as the standard address fields.

For you to understand what I mean for special functionality: for example, when creating an account you have two addresses: Billing and Shipping Address. These addresses can be synchronised.
However, if you create your custom fields, unless you customise the feature for synchronisation, they will not be synchronised.
There are a few other special features beyond that of my example.

Hi amariussi, thanks for your reply.
As I wrote in my post above I have already searched the forum and found several posts about the subject. I do not know which to follow.
If you know the correct procedure and you could tell me the precise post to follow?
There is nothing ready for Italy.
I’m not very practical suitecrm and I’m starting to use version 1.7.3.
Thank you very much for the help.

I tried to follow this guide but I can not make it work :frowning:

Try this )I hope I didn’t do any mistake, but it should work if you follow these instructions):
(if you need to generate a list faster, if you have the list of all the countries, conties and citiesl in a mysql database, I think I can help you too to avoid you entering all the data by hand, but you need to have the database)

  1. Create the Countries dropdown
    go to Admin->Developer Tools->Dropdown Editor->Add Dropdown
    in the Name field enter the name of your dropdown (for example “my_countries_list”) and then proceed below to add items to the list by filling the Item Name and Display Label textboxes and then click on the Add button.
    Here are some values:

Item Name: uk
Display Label: United Kingdom

Item Name: fr
Display Label: France

Item Name: it
Display Label: Italy

Item Name: es
Display Label: Spain

At the end of the process press the Save button and you have finished creating the parent dropdown

  1. Create 1st level Child dropdown
    go to Admin->Developer Tools->Dropdown Editor->Add Dropdown
    in the Name field enter the name of your dropdown (for example “my_counties_list”) and then proceed below to add items to the list by filling the Item Name and Display Label textboxes and then click on the Add button.
    Here are some values:

Item Name: uk_lon
Display Label: London

Item Name: uk_bham
Display Label: Birmingham

Item Name: uk_man
Display Label: Manchester

Item Name: fr_par
Display Label: Paris

Item Name: fr_lyo
Display Label: Lyon

Item Name: fr_nic
Display Label: Nice

Item Name: it_rm
Display Label: Rome

Item Name: it_ml
Display Label: Milan

Item Name: it_ve
Display Label: Venice

Item Name: it_fi
Display Label: Florence

Item Name: es_mad
Display Label: Madrid

Item Name: es_bar
Display Label: Barcelona

Item Name: es_val
Display Label: Valencia

At the end of the process press the Save button and you have finished creating the child dropdown

You will have noted that the counties from the United Kingdom are prefixed with uk_: this is the name of the item in the countries_list to which we added an underscore.
The same applies to other countries: es_, fr_, it_

If you sort these items you will note that the prefix is ignored in the sorting.

  1. Create 2nd level Child dropdown
    go to Admin->Developer Tools->Dropdown Editor->Add Dropdown
    in the Name field enter the name of your dropdown (for example “my_cities_list”) and then proceed below to add items to the list by filling the Item Name and Display Label textboxes and then click on the Add button.
    Here are some values:

Item Name: mi_mi
Display Label: Milan

Item Name: mi_as
Display Label: Assago

Item Name: mi_sd
Display Label: San Donato

Item Name: fi_fi
Display Label: Florence

Item Name: fi_sc
Display Label: Scandicci

Item Name: rm_rm
Display Label: Rome

Item Name: rm_an
Display Label: Anguillara

Item Name: rm_la
Display Label: Ladispoli

At the end of the process press the Save button and you have finished creating the child dropdown

  1. Create the Parent field in Studio
    In this example we will add these fields to the Contacts module so go to Admin->Developer Tools->Studio->Contacts->Fields->Add Field

In the DataType select Dropdown
In Field name write: my_country
in the Display Label write: Country
in the Dropdown List select my_countries_list

Once done click on the Save button
(you will notice that, once you are taken to the list of fields, your field name will have a trailing _c that the system will have added to it so its name will be country_c)

  1. Create the Child field in Studio
    In this example we will add these fields to the Contacts module so go to Admin->Developer Tools->Studio->Contacts->Fields->Add Field

In the DataType select DynamicDropdown
In Field name write: my_county
in the Display Label write: County
in the Dropdown List select my_counties_list
in the Parent Dropdown write: my_country_c
(Note that this is the name of the field and not the dropdown)

Once done click on the Save button
(you will notice that, once you are taken to the list of fields, your field name will have a trailing _c that the system will have added to it so its name will be my_county_c)

  1. Create the second level Child field in Studio
    In this example we will add these fields to the Contacts module so go to Admin->Developer Tools->Studio->Contacts->Fields->Add Field

In the DataType select DynamicDropdown
In Field name write: my_city
in the Display Label write: City
in the Dropdown List select my_cities_list
in the Parent Dropdown write: my_counties_c
(Note that this is the name of the field and not the dropdown)

Once done click on the Save button
(you will notice that, once you are taken to the list of fields, your field name will have a trailing _c that the system will have added to it so its name will be my_city_c)

  1. Add the fields in the Edit Layout
    go to Admin->Developer Tools->Studio->Contacts->Layouts->Edit View

Drag a new row to the layout
In the left filler drag the my_country_c field and in the right filler drag the my_county_c field

Drag a new row to the layout
In the left filler drag the my_city_c field

Then click on Save and Deploy and you can proceed to test.

Thanks again for your reply.
The procedure you have indicated seems to me you need to create dynamic DropDown for Country / Province / City.
This to me is quite clear.
The thing I can not do is replace the new fields with the default fields, grouped in (Billing Address / Shipping Address) in the form Companies and Contacts.
In fact, even in the previous post you’ve written

I would not lose the functionality of the fields default address.
What should I do after creating my DropDown, to display the address fields as DropDown not text?

I have a DataBase to import Region / Province / City for Italy. I attach the DB because you can help me to import all the data, and I thank you very

I noticed that this change is in high demand, perhaps it can be useful for other members.

I am not sure I understand what you mean by:

In any case to maintain the same functionality as in standard address fields you need to write a lot of code so, unless you know how to do it, it will be quite difficult.
Personally I believe that the way in which SugarCRM has implemented addresses is not very smart because addresses may vary from country to country.
I have to manage several companies that have many addresses and this is not foreseen, for example. Furthermore, in Spain addresses tend to include also the floor and the door on the floor and, again these fields are not foreseen.
Furthermore, by giving the ability to chose from dropdowns reduces the risk of mistakes and makes search results more reliable (with the standard address fields one could search for “London”, “Londres” or “Londra” and get different results. If, instead there is a dropdown you can only search for the value in the dropdown that represents London!

Anyway we can’t change this.

Concerning your file:

I have checked the file you sent but to create a file ready for SuiteCRM I also need the list of Regions and Provinces with their respective codes. What you sent me has the Towns (comuni) only and their associated province code (not the province name) and region (not region code).

I could try to define a code for the regions by taking the first 3 letters, but how can I get the province names from their code?

I also understand that you are not interested in the list of countries (in case you do I think I have a list of countries in English with their respective two or three letter ISO codes, but I don’t have regions, counties and cities of the world)

I agree with what you say

Precisely for this reason I would like to manage the addresses with DropDown.
I attach even the tables of the Provinces and Regions that have fields related to table municipalities that I posted earlier.
At the moment I’m not interested foreign states
Thank you

Thanks guys it help me lot :slight_smile:

Hello amariussi, have you looked at the other tables that I have attached?
Do you think you can proceed with the import?
Thank you

I wrote a php script to create the files you need from the zip files you attached. But I haven’t finished yet because I found some problems. I will post it later today after I test it…

1 Like

OK I finished it and tested it.
I also noticed that there was an error in my explanation: in front of the cities code you also have to append the region code, otherwise it doesn’t work.

I am attaching a zip file containing a file called rpc.php.zip which in turn contains a file called rpc.php.

BE CAREFUL with this file!

Follow these instructions:

  1. Check the Folder custom/include/language
  2. I the folder exists go to step 4
  3. If the folder does not exist go to Admin->Developer Tools->Dropdown Editor and, once inside click on Add Dropdown.
    Create a dropdown with only one empty element and give it a name that does not exist (for example HHHHHHTTTTT). Once done. Save and exit from Dropdown Editor
  4. Go to custom/include/language and edit all the language files you find there (one for each language)
  5. For each file that you find go to the bottom and copy after all the content of the file the content of the file I sent you. (before you should open it, then select all, then copy, then go to the language file and paste at the end)
    Be careful not to modify anything else.
  6. Once you have finished adding to all the language files, and if you had followed also step 3, go back to Admin->Developer Tools->Dropdown Editor and delete the dropdown you had previously created with the name HHHHHHTTTTT.
  7. Go to Admin->Developer Tools->Studio->Accounts and add the following fields:
    a. Regione (Dropdown) select irpc_regioni from the dropdown menu). Take a note of the system name of the field (it should be regione_c if you called it Regione)
    b. Provincia (DynamicDropDown) select irpc_province and in the parentr dropdown write the system name of the Regione field (regione_c)
    c. Comune (DynamicDropDown) select irpc_comuni and in parent dropdown write the system name of the Provincia field (provincia_c)
  8. Edit the Layout for accounts and add the three fields and then save and deploy
  9. Test

If you want you can add the fields also in other layouts.

NOTE: All this is at your own risk. Although everything should be OK, I recommend that you do a full backup.
If you can’t do it at least of the files you modify.

1 Like

Hi amariussi, it works well the file you sent me. Thank you very much for the work you’ve done is very useful. :slight_smile: :wink:
I would go back to understand what we said at the beginning.
To use the new fields that we have created (dropdown) would be better to turn off the default fields in the masks of the modules. is that right?
Instead, if I want to replace the default fields with dropdown fields that we have created you can follow this guide?
I tried but did not succeed. Others seems that they have succeeded, I definitely something wrong.
What do you think about it?
Thanks again for the support you are giving.

I have seen the guide very superficially but I have never tried. It seems to me that, since it modifies some core features of the standard address fields, there may be certain other features that may not work as they should. Maybe I am wrong.

Possibly the SuiteCRM team can provide some more information.

In the meantime I will look at the guide and try it.

Okay, I expect you to do a test and let me know.

Then I want to know if this is correct
To use the new fields That We have created (dropdown) would be better to turn off the default fields in the masks of the modules. is that right?

It is really your choice.

If you only have Italian addresses it may be a good idea. But if you have addresses from other countries, either you leave the standard fields and have to cope with both custom and standard or you have to create the lists of counties and cities for every country (hardly feasible).

You could try to create an after_save logic hook (maybe you could also do it with a workflow or a scheduler) that copies the data from the dropdowns to the standard fields (but if you do this you have to know if you want the data from the dropdown or the data entered in the field. Maybe with a user option flag).

There are many possible scenarios so, as you see it depends on what you want to do.

Hi amariussi, I thought I had solved, but I did not realize that the values of the tendon are all open. Clicking in order Region, Province filters work, but the problem remains that before opening the values are all visible it should be seen only region.
It should work with the values of the curtains closed.
I select the first region, then opens Province.
They select the Province and then opens common.
When you’ve done the tests worked well? Or is it a bug as I wrote in this post?

I have tested it and it worked fine for me. I tried both on a pc under windows and wamp as well as on an online server running Linux.

The only issue I noted ist that, since there are are approximately 1000 entries in total, it is advisable that you wait a bit when selecting from the various items in order to allow the system to load the list.

Thanks for the reply. I’m going crazy for two days :frowning: .
You could try my file? I can not make it work, perhaps because the same module I have other DropDown?
Thank you

These are my files I uploaded to custom/include/language
Thank you very much if you can try these files by placing all dropdown fields in the module Account
I hope you can help me.