Using Glide Script to Reference Specific Field from Variable

codechaser
Giga Expert

I am needing to reference the 'short_description' field from the kb_knowledge table.   Currently, the default field is number.   I've been working with the glide record, below to call on the short_description field from the table, but not sure it is a valid qualifier.

javascript: var knowledge = new GlideRecord('kb_knowledge'); knowledge.get(gs.getReference());knowledge.short_description;

Any help is appreciated!

1 ACCEPTED SOLUTION

randrews
Tera Guru

ok if you just want the short description to show when the click the sply glass.. you can click the spy glass and in the popup window right click the header for the list .. click configure list layout.. and add it.....



if you want to configure what shows when you enter a value .. and how it searches you can do this with the ajax table compleater by setting an attribute on the kb_knowledge table... <or an attribute on that one ref field if you only want to affect that field...http://wiki.servicenow.com/index.php?title=Auto-Complete_for_Reference_Fields#gsc.tab=0



if you want to change what is shown in the box itself you can change the display value for the table.. but i HIGHLY recomend you do NOT do this   as short descriptions are to long to fit in the field and it is a really bad idea...


View solution in original post

3 REPLIES 3

randrews
Tera Guru

ok i am a little confused by what you are doing here.. is this in a reference qualifier or where??


what table are we querying from and what are you going to do with the data?



also you need to modify this part...




knowledge.get(gs.getReference());knowledge.short_description;



getReference gets a reference based on a sys_id so that should probrably be



knowledge.get(gs.getReference(ref_field_name.sys_id));knowledge.short_description;



and i am not sure what the knowledge.short_description is doing?


Thanks Raymond!   Essentially, I am just trying to change the default field the reference variable points to from the kb_knowledge table.   Right now, the drop-down only shows KB numbers - I need short_description.


randrews
Tera Guru

ok if you just want the short description to show when the click the sply glass.. you can click the spy glass and in the popup window right click the header for the list .. click configure list layout.. and add it.....



if you want to configure what shows when you enter a value .. and how it searches you can do this with the ajax table compleater by setting an attribute on the kb_knowledge table... <or an attribute on that one ref field if you only want to affect that field...http://wiki.servicenow.com/index.php?title=Auto-Complete_for_Reference_Fields#gsc.tab=0



if you want to change what is shown in the box itself you can change the display value for the table.. but i HIGHLY recomend you do NOT do this   as short descriptions are to long to fit in the field and it is a really bad idea...