Refactor existing "Compare roles"-script and update readme to link to OOTB functionality#1972
Merged
Paulsylo25 merged 2 commits intoServiceNowDevProgram:mainfrom Oct 9, 2025
Conversation
Refactored the script making the followingimprovements: - username_a and username_b renamed to usernameA and usernameB for consistent camelCase naming on lines 6–7. - set_a and set_b renamed to rolesUserA and rolesUserB for clearer intent on lines 9–10 and 44–45. - Duplicate role-fetching logic for each user replaced with reusable getUserRoles() function on lines 12–24. - Role uniqueness ensured using indexOf() check inside getUserRoles() on line 22. - Role comparison logic using concat() and filter() replaced with explicit difference() and intersection() functions on lines 26–39. - gs.print() replaced with gs.info() for consistent platform logging on lines 47–49. - Inline comments added to explain configuration, function purpose, and output sections throughout the script.
Updated the readme to reflect the changes to the script. Additionally, included the link to Access Analyzer which provides Role comparison in the UI OOTB
Contributor
|
Looks good for me! Thanks for your contribution |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description:
This PR contains 2 improvements:
To me the most important one is that in the readme we now refer to OOTB functionality. But I decided to improve the script while I was at it as well.
Update compare-roles-2-users.js
Refactored the script making the followingimprovements:
Update README.md
Updated the readme to reflect the changes to the script. Additionally, included the link to Access Analyzer which provides Role comparison in the UI OOTB
Pull Request Checklist
Overview
Code Quality
Repository Structure Compliance
Core ServiceNow APIs/Server-Side Components/Client-Side Components/Modern Development/Integration/Specialized Areas/Documentation
Restrictions