Select the column in the reference type variable

jkelvynsant
Tera Contributor

Hello community, I have a reference variable that by default shows the "Name" column, but I need the "u_managed_by" column to be visible only in this case. I applied this scriptCaptura de tela 2026-03-18 122941.png

But the display ended up like this:

Captura de tela 2026-03-18 123030.png

3 REPLIES 3

Rafael Batistot
Kilo Patron

Hi @jkelvynsant 

 

Share the script that you’ve applied for a more assertive answer

 

If this response was helpful, please mark it as Helpful and, if applicable, as Correct, this helps other users find accurate and useful information more easily.

_guinther
Tera Contributor

Use a Formatter / Auto-populate field:

Instead of trying to change the reference display:

Keep reference variable normal (shows Name)

Add another variable (read-only)

Populate it with u_managed_by

Example Catalog Client Script:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || !newValue) return;

    var ga = new GlideAjax('GetManagedBy');
    ga.addParam('sysparm_name', 'getValue');
    ga.addParam('sysparm_sys_id', newValue);
    ga.getXMLAnswer(function(response) {
        g_form.setValue('u_managed_by_display', response);
    });
}

 

Script Include:

var GetManagedBy = Class.create();
GetManagedBy.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getValue: function() {
        var gr = new GlideRecord('your_table');
        if (gr.get(this.getParameter('sysparm_sys_id'))) {
            return gr.u_managed_by.toString();
        }
    }
});

 

Ankur Bawiskar
Tera Patron

@jkelvynsant 

By default whichever field is marked as Display=true on that table will be shown once you select the reference value

If you wish to change it to some other field then it would be a global impact so wherever this table is being referred it will start showing Managed by instead of Name

Note: please discuss this with your customer

OR

Another approach is to use Lookup select box variable and point to that table

In Lookup label field give -> u_managed_by

Example like this:

AnkurBawiskar_0-1773976408975.png

 

Output

AnkurBawiskar_1-1773976408891.png

 

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader