Convert SysId Of List Collector to Display Value

Pintu2
Tera Expert

Hi All,

I have record producer with a variable List Collector referring to cmdb_ci table and mapped to text field (short description on Incident table ) so when I submit this form it displays sysid's of below selected CI's in Short Description field as highlighted in below screens.Is there any way to show theDisplay Value(Name) of CI's in Short Description field.

Appreciate your response !

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

dvp
Mega Sage

Please try the below script



    var test = producer.YOUR_FIELD_NAME.toString();



     


      if (test != '') {


     


      var myString1Split = test.split(',');


      var str = '';


      for(i = 0; i < myString1Split.length; i++) {


             


              var mylst = new GlideRecord('cmdb_ci');


              mylst.addQuery('sys_id', myString1Split[i]);              


              mylst.query();


             


              while(mylst.next()){


                      str += mylst.name + ', ';


              }


      }


              current.short_description = str;


      }


View solution in original post

6 REPLIES 6

FYI, you don't have to use a script to iterate over the sys_ids. As I mentioned before, you simply need to do



current.short_description = producer.selected_list.getDisplayValue();   // replace selected_list with your variable name



and it'll populated Short Description with the Display Values of the sys_ids like below:


find_real_file.png


This is a simpler and more maintainable solution.


jagielskij
Kilo Explorer

Dear drjohnchun

Would you be able to explain where shall I use that syntax?

Is it on record producer or incident form it should be implemented? 

Additionally in which particular place i.e. script section of record producer/incident form ? 

Apologies for perhaps basic questions but I am very new to servicenow . 

 

Thanks in advance for your help 

 

Jacek