Missed Team ’24? Catch up on announcements here.

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

get the creation date of a user

valerian Baillet May 22, 2018

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

7 votes
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 22, 2018

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;
valerian Baillet May 23, 2018

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?

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 23, 2018

List<GenericValues>

valerian Baillet May 23, 2018

ok thank you.

Jamie MacDonald April 22, 2020

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?

Quentin Mahé April 27, 2020

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

1 vote
Rocio Razquin November 4, 2022

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!

0 votes
Scott Boisvert April 28, 2022

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

0 votes
Sam Gerzon March 9, 2022

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! 

Nicolás Figueroa March 11, 2022

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
Sam Gerzon March 11, 2022

That worked! Thank you so much!!!

Sam Gerzon March 22, 2022

@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.

Nicolás Figueroa March 22, 2022

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
AUG Leaders

Atlassian Community Events