The reason why there are empty roles is that whenever a role is deleted, the associated sys_user_has_role is not getting deleted and is instead showing empty. 

Steps to Reproduce

  1. Create a test role
  2. Add users to it
  3. Delete this role.
  4. Empty roles now exist in the sys_user_has_role table.


There isn't a workaround to prevent the issue from happening again, while in Express. However, a cleanup script removes these empty roles:

  1. Take a backup of the sys_user_has_role table
  2. Run the following script
    function deleteEmptyRoles() {
    //script to delete the empty roles a user contains
    var roleL = [];
    var gr = new GlideRecord("sys_user_has_role");
    gs.print("Number of records that will be deleted: " + gr.getRowCount());
    while (gr.next()) {
    gs.print("the sys_ids of the records that will be deleted are: ");
  3. Take a note of the sys_id(s) of the sys_user_has_role records
  4. Navigate to the sys_user_has_role list, and use the filter [Sys ID] [Is one of] [the sys_ids that are copied in the above step]
  5. Ask the customer to cross verify if these are the records that need deletion
  6. Run the script again, this time by uncommenting the deletion part

Related Problem: PRB1091271

Seen In


Associated Community Threads

There is no data to report.

Article Information

Last Updated:2017-11-16 16:25:32