The Adaptavist Group LogoDocumentation

Work with Users

With HAPI, you can create scripts to gather lists of users based on different criteria and deactivate users.

Tip: Expanding on these scripts

You can use the methods outlined on this page with other HAPI methods.

Get user by name

To get a user by username and return their email address, enter a script like this in the Script Console:

Enter a script like this in the Script Console:
Users.getByName('USERNAME').email
After you run this script, the user email is printed in the log:

Deactivate users

To deactivate a user, enter a script like this in the Script Console:

Enter a script like the following in the Script Console:
Users.getByName('USERNAME').deactivate()
After you run this script, the user is deactivated. When you navigate to the Users screen, you can see the disabled flag next to the user:

Get inactive users

  • To get a list of inactive users, including deactivated users, use a script like this in the Script Console:
    import java.time.temporal.ChronoUnit
    import java.time.Duration
    
    Users.getInactiveUsers(Duration.of(90, ChronoUnit.DAYS)).collect { it.name }
    After you run the script, you will have a list of users that have been inactive for 90 days.
  • You can change the period of inactivity by adjusting the Duration.of(90, ChronoUnit.Days)) to how long you need, like, Duration.of(6, ChronoUnit.DAYS)). Visit Oracle ChronoUnit documentation for help.

Get logged in user

To get the current logged in user, use a script like this in the Script Console:

Use a script like the following in the Script Console:
Users.getLoggedInUser()
After running this script, you get a list of users who are logged in:

Search documentation

Start typing to search the docs.