Babu
New Creator

Help with Dynamic Population of Combo Boxes in FirstSpirit Based on Selected Country

Hi FirstSpirit Community,

I’m working on a project where I need to dynamically populate the legal entity combo box based on the selected country combo box using FirstSpirit's <CMS_MODULE>.

Current Setup

I’ve set up two combo boxes in FirstSpirit:

  1. Country Combo Box (tt_country_list) pulls data from the privacy_country table.
  2. Legal Entity Combo Box (tt_legal_entity) should pull data from the privacy_legal_entity table, but it needs to be filtered by the selected country.

My Code

Here is the code I’m using in the module:

<CMS_MODULE>

  <CMS_INPUT_COMBOBOX name="tt_country_list" hFill="yes" singleLine="no" useLanguages="no">
    <CMS_INCLUDE_OPTIONS type="database">
      <LABELS>
        <LABEL lang="*">#item.countryName </LABEL>
      </LABELS>    
      <TABLE>webworld.privacy_country</TABLE>
    </CMS_INCLUDE_OPTIONS>
    <LANGINFOS>
      <LANGINFO lang="*" label="Select Country" description="Select Country"/>
    </LANGINFOS>
  </CMS_INPUT_COMBOBOX>

  <CMS_INPUT_COMBOBOX name="tt_legal_entity" hFill="yes" singleLine="no" useLanguages="no">
    <CMS_INCLUDE_OPTIONS type="database">
      <LABELS>
        <LABEL lang="*">#item.entity_name</LABEL>
      </LABELS> 
      <QUERY name="">
      </QUERY>    
      <TABLE>webworld.privacy_legal_entity</TABLE>
    </CMS_INCLUDE_OPTIONS>
    <LANGINFOS>
      <LANGINFO lang="*" label="Select your Entity" description="Select your Entity"/>
    </LANGINFOS>
  </CMS_INPUT_COMBOBOX>

</CMS_MODULE>

 

Issue

The problem is that I can't seem to figure out how to properly filter the legal entity combo box based on the selected country. I’ve attempted to use the <QUERY> tag, but I’m unsure how to structure it to reference the selected country in the first combo box (tt_country_list).

 

What I Need

Could anyone guide me on how to:

  • Properly filter the privacy_legal_entity table based on the selected country from the privacy_country combo box?
  • Use the correct FirstSpirit query or filtering mechanism to achieve this?

Any insights or examples would be greatly appreciated!

Thanks in advance for your help.

0 Kudos
1 Reply
mbergmann
Crownpeak employee

Hi Babu,

this should be possible using a <RULE>. Please have a look at the documentation here - see the section "Exception: setting dynamic values using a database query".

Best,

Michael

0 Kudos