List field displaying sys_id rather than name after being saved

Sam Ogden
Tera Guru

Hi All,

We have created a list field on our incident table called u_escalated_to.. This is a reference to the sys_user_grmember table and has a simple filter of Group is SM Managers.

When you first select the name in the list it displays correctly.

find_real_file.png

Once you save the record it is displaying as the Sys_ID

find_real_file.png

Any suggestions on how to get it to retain the name rather than the sys_id?

Any help is greatly appreciated

Thanks

1 ACCEPTED SOLUTION

Sorry Sam. Mistake on my part. Go to the script include and change the line:



list.push(grm.getValue('sys_id'));



to



list.push(grm.getValue('user'));



The list was creating a bad list of sys_ids.


View solution in original post

36 REPLIES 36

Hi Chuck,



Thanks for the above.   I have another example of a list collector I am trying to use, but this time it is on a record producer on our portal.   The List Collector is a reference to the core_company table.   I then have the below code to copy the information from this record producer into the description field of the incident that it creates :


if(producer.all_brands_affected !=""){


current.description = 'Brands Affected: ' +producer.all_brands_affected;


}



This however is copying sysID to the description field and not the name of the companies. Is this the same issue or is it something wrong with the above code?



Thanks


That doesn't sound like the same issue. It's getting the value by default and you want the display value. Try this instead:



if (producer.all_brands_affected !=""){


        current.description = 'Brands Affected: ' + producer.all_brands_affected.getDisplayValue();


}


Thanks that has worked fine.



In regards to the original issue on the List collector I've added to the incident form, is there any OOB functions that I could use to create the reference Qual to return the users who are members of the SM Managers group from the sys_user table, or will I need to create a script includes to run a query against the sys_user_grmember table?



Thanks


Hi Sam,



There isn't anything OOB that I'm aware. You are welcome to try this bit of code that I just put together. Warning: It hasn't been tested.



From a reference qualifier, you could call it like this:



javascript:new UserUtil().getGrMemberQuery('GROUPNAMEHERE');



It should return an encoded query something like this:



sys_idINSYSID1,SYSID2,SYSID3...


////////////////////////////////////////////////


var UserUtil = Class.create();


UserUtil.prototype = {


      initialize: function() {


      },



        // Get the encoded query for a reference qualifier


        getGrMemberQuery : function(groupName) {



                  var memberList = this.getGroupMemberList(groupName);



                  return 'sys_idIN' + memberList.join(',');


        },



        // Return an array of group members


        getGroupMemberList : function(groupName) {



                  var list = [];


                  var grm = new GlideRecord('sys_user_grmember');


                  grm.addQuery('group.name', groupName);


                  grm.query();



                  while (grm.next()) {


                            list.push(grm.getValue('sys_id'))


                  }



                  return list;



        },


      type: 'UserUtil'


};


Hi Chuck,



Thanks for the above, I've just tried this, but the filter doesn't appear to have worked, not sure if I've missed a section that I should have amended etc.:



Ref Qual = javascript:new getGroupMembers().getGrMemberQuery('SM Managers');



Script Includes:


find_real_file.png


Currently the list is showing all users from the sys_user table.


Any help is greatly appreciated.