getDisplayValue for Glide List is giving sys_id

chaslage
Kilo Guru

Not sure why but the getDisplayValue for the Glide List is coming out as sys_ids.   This Glide List (u_linked_records) is a list of entries in the Task table.

 

       var newLR = current.u_linked_records.toString();   //New Array of the Linked Records
       gs.log('SYS_ID Value: '+current.u_linked_records.toString());
       var newLRArr = newLR.split(",");
   
       var newLRNum = current.u_linked_records.getDisplayValue();   //New Array of the Linked Records with Numbers
       gs.log('Display Value: '+current.u_linked_records.getDisplayValue());
       var newLRNumArr = newLRNum.split(",");


Result:

 

SYS_ID Value: 217a717934be11003fd4f7967b28e115,52bebd7934be11003fd4f7967b28e194

Display Value: 217a717934be11003fd4f7967b28e115, 52bebd7934be11003fd4f7967b28e194

 

Any help would be appreciated.

 

Thanks!

1 ACCEPTED SOLUTION

Lam_Hoang
Kilo Expert


this should work fine for you.



https://wiki.servicenow.com/index.php?title=Referencing_a_Glide_List_from_a_Script



Did you check if you display value is set to true for the dictonary field 'number' on the task table?



Tested on calgary instance, and its working fine for me.




var gr = new GlideRecord('incident');


if (gr.get('9d385017c611228701d22104cc95c371')){


gs.print(gr.number) //show me the current incident nummer


var newLRNum = gr.u_related_records.getDisplayValue();


gs.print(newLRNum)//show me the display value of the watchlist.


}



*** Script: INC0000002


*** Script: CHG0000001, CHG0000002


View solution in original post

12 REPLIES 12

linked records is a reference field so you are ending up retrieving the record that contains the link.. not the reference field value...



i would probably thumb through the linked records... using get reference to get the referenced object.. then you can get the correct name.


Lam_Hoang
Kilo Expert


this should work fine for you.



https://wiki.servicenow.com/index.php?title=Referencing_a_Glide_List_from_a_Script



Did you check if you display value is set to true for the dictonary field 'number' on the task table?



Tested on calgary instance, and its working fine for me.




var gr = new GlideRecord('incident');


if (gr.get('9d385017c611228701d22104cc95c371')){


gs.print(gr.number) //show me the current incident nummer


var newLRNum = gr.u_related_records.getDisplayValue();


gs.print(newLRNum)//show me the display value of the watchlist.


}



*** Script: INC0000002


*** Script: CHG0000001, CHG0000002


This is exactly what I had to do, which was an extra step I am not happy about.   I should be able to just directly reference.   Meh.   It's done.


How would you implement this on a record producer?


for as I'm aware there is no List element for record producers/ catalog items. What do you want to achive?