Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,461,485
Community Members
 
Community Events
176
Community Groups

get the creation date of a user

Hi,

I try to develop a plugin and I need to know the creation date of each user. I don't think that it's possible using java classes so I try to use ActiveObject but I didn't know how to do that.

 

Can somebody help me?

 

Regards

4 answers

1 accepted

5 votes
Answer accepted

Hello,

You can do it like this:

import com.atlassian.jira.component.ComponentAccessor
def users = ComponentAccessor.getOfBizDelegator().findAll("User");
def usernames=new ArrayList<String>();
users.each{user ->

usernames.add(user.getString("createdDate"))
}
return usernames;

Thank you for your answer.

I have just one more question. What is the type of users ? I use java so I need the type.

 

Can you help me?

List<GenericValues>

This was exactly what I was looking for, but I would like to have the output be sorted by createdDate, how can I do this?

This is how I sort an array of objects, which contains username/date of creation/last login date, sorted by username :

Return = tempReturn.toSorted{a, b -> a.Username <=> b.Username}

where tempReturn contains all the objects, and Return is the final result. It's probably not the best way to do it, but it works for me, and I'm not concerned by performance obligations so I just need something that works, I'll clean/improve it later (I'm a bit rusty on the dev side, haven't done any in the past 5 years)

More infos there : https://mrhaki.blogspot.com/2015/03/groovy-goodness-new-methods-to-sort-and.html

There is now a feature request (https://jira.atlassian.com/browse/JRASERVER-74496) in Atlassian's backlog to get the method getCreatedDate() added to one of the existing user objects: com.atlassian.jira.user.ApplicationUser or com.atlassian.crowd.embedded.api.User.

Anybody coming to this community article and interested in having the method added please vote the request to get traction!

Thanks!

Anyone know how to get the user's created date in Confluence?

I ran the following in ScriptRunner console:

import com.atlassian.jira.component.ComponentAccessor
def users = ComponentAccessor.getOfBizDelegator().findAll("User");
def usernames=new ArrayList<String>();
users.each{user ->

usernames.add(user.getString("createdDate"))
}
return usernames;

The output appears to return the create date, but does not return the users names for some reason, can anyone assist?

Thanks! 

Hello Sam,

With this simple modification you could get the Username and CreatedDate

 

import com.atlassian.jira.component.ComponentAccessor
def users = ComponentAccessor.getOfBizDelegator().findAll("User");

def usernames=new ArrayList<String>();

users.each{user ->

usernames.add(user.getString("userName"))
usernames.add(user.getString("createdDate"))
}


return usernames;

Like Sam Gerzon likes this

That worked! Thank you so much!!!

@Nicolás Figueroa Your help is much appreciated. 

How would I edit the script to return just active users? I can't seem to find the solution.

Hello Sam,

In a quick way to do it is to add:

usernames.add(user.getString("active"))

 

If active:1 (True, Active) and active:0 (False)

But also you can get that info in "User Management" > "Users"

Screenshot 2022-03-22 200216.png

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events