Remove multiple users from custom user set

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
Is there a way to quickly remove multiple users from a User type field in the custom user set dialog?  I have over a hundred users, and having to click on each one to remove them is giving me carpal tunnel syndrome!   :)
Photo of slloydavant

slloydavant

  • 80 Points 75 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
I wish, but no.

I also wish you could make those user fields only show users in a certain "Role".  That would make things so much faster and clean.
(Edited)
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,402 Points 20k badge 2x thumb
Of course there is a way to do this with script. The answer to every question of the type "is it possible?" is YES if you use script.

You modify the <select> to add a multiple attribute so multiple users can be selected and then further modify the RemoveUser() function (original shown below) to have the behavior you want.

function RemoveUser(id) {
  var select = document.getElementById(id);
  if (select.selectedIndex == -1) {
    showError("You must first select a name to remove from the list.");
    return
  }
  if (!IsExplanatoryOption(select.options[select.selectedIndex])) {
    var saveIndex = select.selectedIndex;
    select.options[select.selectedIndex] = null;
    if (saveIndex < select.options.length) {
      select.selectedIndex = saveIndex
    }
  }
}