The CreatorCon Call for Content is officially open! Get started here.

How to display country code as country name?

Buddy 1
Tera Contributor

I have a country field in 'ABC' case form, Based on account field in that form , the country field is displaying the value for ex: DE , but i have to achieve this as Germany , i.e., when account is selected , the country field should display as Germany instead of DE. 

Basically the country field is dot-walked from form layout,,--> account.country

When checking on configure dictionary , the table name is core_company
When i click on show country field: These are the below info 

Table: sn_customerservice_case

Field :account

Type: reference

Reference: customer_account

Reference Qual :new global.GenericUtils().getContactAccounts(current.contact.user_name );

Max Length : 32

 

 

How to achieve this with client script , i.e.., make the country field display country name instead of country code?

 

Thanks in advance!

10 REPLIES 10

AnubhavRitolia
Mega Sage

Hi @Buddy 1 

 

You need to make 'Country Name' as Display instead of 'Country Code' in Country Table.

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Youganshu G
Tera Contributor

Hi,

Open the table which is referencing to account field and from Column List form section, change the "display" field value to true which you want to show. For ex. if you want the name to be displayed on the form and not the code, then set display field value of Name column to true and Code column value to false.

 

Please mark helpful if it resolves your issue.

 

AnubhavRitolia
Mega Sage

Hi @Buddy 1 

 

You can create a custom string field 'Country' which will auto populate Country of Account.

 

You can achieve it using below onChange Client Script on Account field:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (newValue === '') {
        return;
    }
var account = g_form.getReference('account', doAlert);

}

function doAlert(account) { 
                g_form.setValue('u_country', account.country.name);
            }

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Hi @AnubhavRitolia ,

Can you help me , after creating a custom country field, how to auto populate a country name based on account we choose. Because as of now it is matching the record from customer_account table