We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Reference field display value

SanikaK
Tera Expert

I have to create a new variable 'Application AIR ID' referencing to 'u_air_attributes' table & the 'Application AIR ID' should display the Application ID's.
But the problem is when I am creating the reference variable it displays the 'Application Name' as the display value is true for it in 'u_air_attributes' table. I cannot change the display true as the table is owned by other team & also it will affect globally.
How can I achieve this I tried using the variable attribute -
ref_auto_completer=AJAXTableCompleter,ref_ac_columns=u_application_id,ref_ac_columns_search=true,ref_ac_display_value=false

But this shows both the Application Name & Application ID and also when I select any option it shows the application name.

3 REPLIES 3

pr8172510
Kilo Sage

 

Hi @SanikaK,

If the requirement is to display only the Application AIR ID without changing the Display field on the u_air_attributes table, one supported approach is to use a Lookup Select Box variable instead of a Reference variable.


Configuration:

Type = Lookup Select Box
Lookup source = Table
Lookup from table = u_air_attributes
Lookup value field = u_application_id

 

 

This displays:

pr8172510_0-1782215672621.png

 

 

 

directly in the catalog item and does not depend on the table's Display field (Application Name).

If a true Reference variable is required, ServiceNow will always display the referenced table's Display Field after selection. In that case, attributes such as

ref_auto_completer=AJAXTableCompleter,
ref_ac_columns=u_application_id,
ref_ac_columns_search=true

 
 

can help users search by AIR ID, but the selected value will still display the table's Display Field.

So for displaying only AIR IDs without changing the table Display field.

Tanushree Maiti
Tera Patron

Hi @SanikaK 

 

For your requirement ,if you need it no code, then instead of reference type variable , use Lookup select box variable.

 

  1. Create variable Application AIR ID.
  2. Select the Type Lookup Select Box.
  3. Go to the Type Specifications tab and configure it as follows:
    • Lookup from table: u_air_attributes
    • Lookup value field: sys_id
    • Lookup label field(s): u_application_id
Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

yashkamde
Mega Sage

Hello @SanikaK ,

 

You can use a client script to visually overwrite what text is shown in the field right after a user selects a record.

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

    var refRecord = g_form.getReferenceRecord(control); 

    control.setDisplayValue(refRecord.u_application_id); 
}

 

If my response helped mark as helpful and accept the solution.