Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to convert sys_id to Display Value in Scheduled Jobs script

TienMinh
Tera Contributor

Hello.  On a table I have a field "u_user_criteria" with list type and contains many values (sys_id) reference to another table. I want to get each Display Value of each value of this field for later use. First I tried to convert the field from string to array of substring, then loop through that array to get each string (each sys_id). Next I tried to convert each of that string of sys_id into Display Value, but I still don't know which way could I achieve that. 

 

   
    var tableCondition = new GlideRecord('u_im_categorization');
    tableCondition.addEncodedQuery('u_active=true');
    tableCondition.query();
    while (tableCondition.next()){ 
         var newUserCriteria = tableCondition.getValue('u_user_criteria');
         var useNewUserCriteria = newUserCriteria.split(",");
         for (var i=0;i<useNewUserCriteria.length;i++){
                //get each useNewUserCriteria[i] (it is currently a sys_id string) and turn it into Display Value.
                // getDisplayValue doesn't work here because I am looping through a field.
         }

    } 

0 REPLIES 0