Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to display different column values on reference fields on a form?

Sai_Dilip
Tera Contributor

So, I have 3 fields on a catalog referenced to "cmn_location" as follows:

1. City

2. State

3. Country

 

Currently the "Name" field on the "cmn_location" table has the Display Value set as "True", but I need to show City, State & Country on the respective fields. Any possible method for this?

6 REPLIES 6

Anand__99
Kilo Sage

Hi @Sai_Dilip ,

 

You can use the Lookup Select box to show the choices from country, city and state field.

 

Anand2799_0-1758272326822.png

 

 

Thanks

Anand

G Ponsekar
Tera Guru

Hi @Sai_Dilip ,

 

you can achieve with onChange Client script.

Field Name : select the primary variable which needs to be used to populate state, country fields. In script I mentioned city as primary variable based on which state and country is populated

you can adjust the code accordingly.

 

You can try with sample code:

function onChange(control, oldValue, newValue, isLoading) {
    // Exit if the form is loading or if no location is selected
    if (isLoading || newValue === '') {
        // Clear the other fields if the location is empty        g_form.setValue('state', '');
        g_form.setValue('country', '');
        return;
    }

    // Get the referenced location record details asynchronously    g_form.getReference('city', function(locationRecord) {
        // Check if a record was found
        if (locationRecord) {
            // Populate the state and country fields with the display values            g_form.setValue('state', locationRecord.state.getDisplayValue());
            g_form.setValue('country', locationRecord.country.getDisplayValue());
        }
    });
}

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

Thanks, GP

 

Nehal Dhuri
Mega Sage

use ref_ac_columns in variable attribute
refer to the screenshot:

NehalDhuri_0-1758272521733.png

 

Please hit like and mark my response as correct if that helps

if you don't want referenced field then you can user Lookup Select box as @Anand__99 suggested

Please hit like and mark my response as correct if that helps