Based on selecting 'location type' as country, state should autopopulate is another field in mrvs.

snriya
Tera Contributor

Hi All,

To add a new location in cmn_location table, I have a mrvs where when user selects a location type say Region or country, then State should present in below parent field.
Similarly when user selects City in location type, parent field should populate sites. 
How to achieve this requirement ?


Refer Below attached snips for better understanding.

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

What is the variable type of 'parent'?  If it is a single row text and you mean this variable should literally be populated with either 'State' or 'sites', you can use an onChange Catalog Client Script within the MRVS:

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
    if (newValue == 'Region') {
        g_form.setValue('parent', 'State');
    }
    if (newValue == 'country') {
        g_form.setValue('parent', 'sites');
    }
}

Use your variable name for the 'parent' variable, and values, not labels for the location type.

Parent is a reference field which will populate values acc to selected location type.

If the parent variable is a reference to the cmn_location table, then instead of the onChange script the reference qualifier will be something like:

BradBowman_0-1728317672787.png

Using your variable name for the location type MRVS variable.  The choice values for the location type MRVS variable must match those of the cmn_location_type field, so if you're not using a lookup select box type variable, or a choice list, make sure they are 'region' and 'country'.

 

 

Hi,

I tried this way but it is giving me parent as countries (in reference) when i am giving location type variable name as country.
I want Parent as states on selecting location type as country. Please correct me if i misunderstood something here.

snriya_0-1728321400317.png

snriya_1-1728322078113.pngsnriya_2-1728322107178.png