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  

How to display "country" field value from cmn_location table in custom field of "LIST" type?

abhi710
Tera Contributor
 
7 REPLIES 7

Hi @Community Alums ,

There is a custom field "Country" of type "List" on custom table, which refers to the cmn_location table. The country name should be displayed in the LIST collector from cmn_location table. How can we achieve this without changing the display value of cmn_location table?

Hi @abhi710, List type fields holds the sys_id of the referenced record in the backend. It is expected that the referenced table's field with display true will be displayed on the form. As per my knowledge, it is not feasible to show the country name from location table on the List type field unless the display is true in the field dictionary.

 

Regards,

Sunil

Community Alums
Not applicable

Hi @abhi710 

Try this and let me know how you get on, feel free to chop and change it.

 

(function executeRule(current, previous /*null when async*/ ) {

    var sourceGr = new GlideRecord('SOURCE_TABLE');

    sourceGr.query();
    while (sourceGr.next()) {

        var destGr = new GlideRecord('DEST_TABLE');
        destGr.addQuery('sys_id', sourceGr.sys_id);

        destGr.query();

        while (destGr.next()) {

            var sourceLocations = sourceGr.getValue('s_location').split(',');
            var destLocations = destGr.getValue('d_location').split(',');

            for (var i = 0; i < sourceLocations.length; i++) {
                var location = sourceLocations[i].trim();

                if (location && !destLocations.includes(location)) {
                    destLocations.push(location);
                }
            }
            destGr.setValue('d_location', destLocations.join(','));
            destGr.update();

        }
    }
})(current, previous);

 

Please mark as helpful or if its resolved the issue, CORRECT!