How to get a entire column(Display value is False) of a table as options to a Reference field

puneethm
Tera Contributor

I have an requirement as: I have three variables in catalog item which are Reference fields say A,B,C all three refer to single table which contain three columns say X,Y,Z but i want to get X column values to A, Y values to B, Z values to C.

Can anyone help me how to do that.

Thanks.

1 ACCEPTED SOLUTION

Please ignore my previous response,



I don't think this is possible, i was just giving a try but no help. As we know only one field can be defined as the display value for a table when you select that field as display true and that field will be visible when you try to select.



You can have he "ref_ac_columns" attribute set in the dictionary for that particular field. Please check the below link for more Auto-Complete for Reference Fields - ServiceNow Wikibut once you select the value, the "display" field will be shown as the reference field's.


View solution in original post

3 REPLIES 3

Harsh Vardhan
Giga Patron

Hi Puneeth,



as per my knowledge you can't set this. may i know what's your business need.


Reason why i am saying it. as per my investigation on reference field , when ever you will make changes in columns it will impact everywhere who's referred this table.


if you click on magnifying glass it opens the record in "sys_ref_list" view for all the field.


Shishir Srivast
Mega Sage

I think you can do that through Advance reference qualifier by calling script include using JavaScript. You might have to create 3 separate Script include for individual fields.



var getName = Class.create();


getName.prototype = Object.extendsObject(AbstractAjaxProcessor, {


subCat : function(){


var names = [];


var gr = new GlideRecord('<table name>');


gr.query();      


while(gr.next())


{


names.push(gr.getDisplayValue('FIELD NAME OF REFERENCE TABLE'));


}


return names;


},


      type: 'getName'


});



Note: I haven't tested this, but hoping this should help.


To call script include in reference qualifier: http://wiki.servicenow.com/index.php?title=Reference_Qualifiers#Advanced_Reference_Qualifier_Example


Please ignore my previous response,



I don't think this is possible, i was just giving a try but no help. As we know only one field can be defined as the display value for a table when you select that field as display true and that field will be visible when you try to select.



You can have he "ref_ac_columns" attribute set in the dictionary for that particular field. Please check the below link for more Auto-Complete for Reference Fields - ServiceNow Wikibut once you select the value, the "display" field will be shown as the reference field's.