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
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

drjohnchun
Tera Guru

Can you show the script that copies selected list to short_description? Can you try



short_description = selected_list.getDisplayValue();



Hope this helps.



Please feel free to connect, follow, mark helpful / answer, like, endorse.


John Chun, PhD PMP see John's LinkedIn profile

visit snowaid


ServiceNow Advocate

Winner of November 2016 Members' Choice Award


dvp
Mega Sage
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;


      }


B_10
Tera Contributor

Thank you.  The way ServiceNow has it setup--apparently needing to loop through and do as many queries as elements instead of just being able to pass a query for all sys_ids in a list is inefficient, and surely slows their system down, but thank you for knowing the nuances of the system like this, it just helped me out

Pintu2
Tera Expert

It worked like a charm Thanks for the response .