Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Change order of choices taken from table reference - CSM

Archana33
Tera Contributor

I have a variable of type 'List Collector', type specification is taken from country table. I want to show a particular country as the first option in the drop down list. Is it possible. Please help.

1 REPLY 1

Mark Manders
Mega Patron

You could try with an advanced reference qualifier and use a script like below. Not sure what it will do to performance though:

(function() {
    var query = "name!=United States^ORDERBYname"; // This query excludes 'United States' and orders the rest alphabetically by name.
    var countries = new GlideRecord('sys_country'); // Assuming 'sys_country' is the name of the country table.
    countries.addEncodedQuery(query);
    countries.query();
    var result = "name=United States"; // Start with 'United States' at the top.
    while (countries.next()) {
        result += "^ORname=" + countries.name; // Append other countries ordered by name.
    }
    return result;
})();

I took 'United States' as an example and I have difficulty waking up my PDI, so not sure if it works. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark