Why doesn't getDisplayValue() obey Dictionary Overrides?



It does, but when you have Dictionary Overrides for Display Value in place on extended tables like the CMDB, you expect using getDisplayValue() to give you the Display value specific to that record's Class (sys_class_name).

e.g. You may have a custom CI Class in the CMDB, where instead of using "Name", you wish for that CI to displayed with the value of some other field, maybe Asset Tag. But your scripts continue to return the CI 'Name' from this function.




You may be using the wrong class when you declare the GlideRecord. The Display value is taken from the GlideRecord object, not the specific record within that.


Use the exact same class for the GlideRecord as of the record.

e.g. 53958ff0c0a801640171ec76aa0c8f86 is the sys_id of a Linux Server (sys_class_name=cmdb_ci_linux_server) in the Demo Data.

The cmdb.asset_tag field has had a Dictionary Override added for that Linux Server class, with 'Override Display' ticked.

var dave = new GlideRecord('cmdb_ci'); // This is the top level table for IT-based CIs. 
gs.print(dave.getDisplayValue()); // This will use 'name' because that is still what cmdb_ci defaults to.

*** Script: lnux100 

var dave = new GlideRecord('cmdb_ci_linux_server'); // this is the actual class of this record
gs.print(dave.getDisplayValue());  // This will use asset_tag, because it will now use the cmdb_ci_linux_server specific override

*** Script: P1000165