You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.