fixes #5338 Script error when you click on role name

Fixed the issue and pushed the code for review, please check it.