Hide/Show drop down values based on another reference field value

Pandu3
Tera Contributor

Hi All,

Based on Country selection, languages should be displayed in Language field on customer_contact record.

1)Country reference field (core_country)

2)Language is drop down list

 

Pandu3_0-1696592349784.png

 

Pandu3_2-1696592747172.png

 

Ex : Country : Austria , Languages : English, German

       Country : Canada , Languages : English

       Country : Netherlands , Languages : English, Dutch

 

Can anyone help me on this requirement. Thanks in advance.

 

 

 

14 REPLIES 14

Satyapriya
Mega Sage

You can use a client script for that.

You have to provide the Syd_id of the country like :

 if (newValue == 'dd38b7111b121100763d91eebc0713f6' || newValue == '0538b7111b121100763d91eebc071') {
        g_form.clearOptions('u_language');
        g_form.addOption('u_language''none''-None-');
        g_form.addOption('u_language''english''English');
    } else if (newValue == '0538b7111b121100763d91eebc0713eb' || newValue == '0538b7111b121100763d91ec') {
        g_form.clearOptions('u_language');
        g_form.addOption('u_language''none''-None-');
        g_form.addOption('u_language''dutch''Dutch');
        g_form.addOption('u_language''german''German');

 

Hi @Satyapriya,

Thanks for your reply.

Country list is to big. So, any other way like configure County & Languages in system property and fetch that property in script. Thanks in advance. 

Satyapriya
Mega Sage

unfortunately you could not since gs.getProperty('name') only works in server side

If you want to store the property value then you can use a display business rule and in the g_scratchpad variable you can store the property and access it from client side.

Please mark it as solution if it's helpful to you.

Regards,

Satyapriya

Hi, Below I'm sharing the script . Please, correct me where am I doing mistake.

system property : {"Austria":["English","French"],"Canada":["English"],"Netherlands":["French","Dutch"]}

 

SI:
getCountry: function() {
var v_country = this.getParameter('sysparm_country');
var fetchLanguageProp = gs.getProperty('country.to.language.mapping');
var result = JSON.parse(fetchLanguageProp);
return result.v_country;
},

 

CS:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    g_form.clearOptions('preferred_language');
    var ga = new GlideAjax('global.LanguageMapping');
    ga.addParam('sysparm_name', 'getCountry');
    ga.addParam('sysparm_country', g_form.getReference('u_country').name);
    ga.getXMLAnswer(getLanguage);
 
    function getLanguage(answer) {
        if (answer != null) {
              g_form.addOption('preferred_language', answer);
        }
    }
}
 
Thanks!

can you alert the answer and check what are you getting there?

 


Raghav
MVP 2023