State visible according to country variable in form

SimranS04382950
Tera Contributor

SimranS04382950_0-1748251189790.png

I have this form in record producer , shipping country and shipping state -> select look up type -> referencing to "cmn_location" table.

I want state and city to comes according to selected country.

i.e. if i select "INDIA" in shipping country then state of India should be visible in "shipping state" variable.

9 REPLIES 9

suhashini more
Tera Contributor

we can do it using on change client script

can you please explain

Bryan Swart
Tera Contributor

This can be accomplished with a client-side script set to onChange, specifically looking at the Shipping Country field. You will want to use a Catalog Client Script since this is a record producer.

 

Something like this:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    // If the selected country is India, set the Shipping State to India
    if (newValue == "India") {
        g_form.setValue('shipping_state', 'India');
    }
}

shipping_state is reference to cmn_location table , and I need to show all the states of India in shipping_state field