How to set a default value from a list of Countries

KS11
Kilo Expert

Hi, 

I was hoping if I can get some help with the following:

I have a catalog reference type variable 'country'.  From a list of 231 countries, I would like the user to see the default as USA and then have the ability to change it to another country. 

I have tried inserting the sys id in the Default tab, it does not work. 

If possible, am looking for a simple method.

 

Thank you for your time in advance.

2 ACCEPTED SOLUTIONS

Hi @KS11 ,

Is there any UI Policy on the location field ?.

See after inactivating that particular UI Policy.

 

Regards,

Johns

View solution in original post

Hi Shraddha, 

It would work without the UI Policy for sure, but the cou try field is dependent on another field, so the UI Policy is a must. 

Thank you for your help though! 

KS

View solution in original post

9 REPLIES 9

Johns Marokky
Tera Guru

Hi @KS11 ,

Default Value will work only when you save the data.

Instead of that you can use the onLoad catalog Client Script as below.

 

JohnsMarokky_1-1680444820934.png

Script :

function onLoad() {
    //Type appropriate comment here, and begin script below

    var userEnteredLocation = g_form.getValue('location');  //give the correct field name
    if (!userEnteredLocation) {
        g_form.setValue('location', '25ab9c4d0a0a0bb300f7dabdc0ca7c1c');  //give the correct USA Sys ID
    }

}

 

Mark Helpful and accept the solution if it helps in solving your query.

 

Regards,

Johns

Hi John, 

Thank you for the help, unfortuantely even this is not working. I tried your approach and Shraddha's approach, it just does not want to work. 

I am wondering if my UI policy is preventing the script from running accurately?

 

Thanks

KS

Hi @KS11 ,

Is there any UI Policy on the location field ?.

See after inactivating that particular UI Policy.

 

Regards,

Johns

Shraddha Kadam
Mega Sage

Hello @KS11 

 

I have created one variable which is refer to the Country Table and kept the default value of the country as "Greece" by adding only sys_id in the default value section. 

In the portal, the default country is visible and also ability to change the another country.

For your reference, please find below image :

ShraddhaKadam_1-1680445206761.png

 

ShraddhaKadam_0-1680445138168.png

ShraddhaKadam_2-1680445254978.png

 

Let me know if you have any question on this.

 

Please mark my answer helpful !

Appreciate your help !

 

Thank you.

 

 

If my response was helpful, please mark it as correct and helpful.
Thank you.