Populate dropdown with records from a related module

I have a module called "States" which contains 51 records of data for the US states. I now need to have data for ZIP codes, which I'm thinking of storing in a module called "ZIP codes" with a One (state) to Many (zip codes) relationship. Is it possible to create a dropdown field populated with the States records and a second dropdown populated to the related ZIP code records, based on the State selected.

The data in the selected ZIP code record will then be used in a mathematical calculation.

We have SugarCRM Professional on demand 

  • You can populate a dropdown from a query as I did, or create a relationship between country and the modules that use them as suggested in the same post:

    https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/2019/create-dropdown-from-module-records/7425#7425

    I am curious about what you are trying to build, maintaining Zip Codes per state sounds like a bit a nightmare... are you importing individual ones from the postal service or just ranges?

    FrancescaS

  • I'm guessing Andre is using on premes and can access the directories. I'm using on demand and can only use Studio.

    We use these to store and calculate insurance premiums. until now we've had a rate that applies to the whole state, but we're currently negotiating with a new carrier and they're suggesting lower rates for some ZIP codes. I'm trying to see how practical it'll be.

  • You don't need to access directories for Andre's solution, and I'm on Premise so I did my coding in the directory itself but you should be able to develop the code on your local development instance and package it to upload it to the cloud - sorry, I'm not familiar with cloud since I've been working on-site for over a decade.

    It sounds like you might just need to store the zip codes for the exceptions to your insurance premiums, which sounds a lot less daunting than all US Zip Codes ;) 

    If you don't have a ton of Zip codes you could possibly get away with dropdowns.

    I use Dependent Dropdowns for country codes and US States/ Canadian Provinces and I've hardly had to change anything in 10 years.

    You could use Dependent Dropdowns for US States and Exception Zip Codes. Though I can see how that might be a problem in that you would need to maintain those from the Admin panel rather than an interface for your Data Entry people...

  • Hi.

    In you para 1 above you mention I can package it up and upload it to the cloud. Can you elaborate that or give me a clue where to look and what it might be called in sugar?

  • Hi you can find the full solution with examples here.

    Regarding how to build an installer package, find here the official documentation.

    Cheers

    André Lopes
    Lampada Global
    Skype: andre.lampada