Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi all,
I'm using JIRA and ScriptRunner. What I'm trying to do is get notification in the event of UserCreatedEvent and inform the name, email and Application access ( such as "Software" or "Service Desk" or "Confluence") to see if the new user consumed a license of any application. I tried to use ScriptListner so that it can email me with those information.
I got it work to send name, email address of the new user but somehow the application info is not sending the correct information. Even though the new user created has a software application access, it doesn't say that so I think I'm missing something.
This is the part of my code (in groovy) to get the application info of newly created user.
import com.atlassian.jira.event.AbstractEvent
import com.atlassian.crowd.event.user.UserCreatedEvent
import com.atlassian.jira.application.ApplicationAuthorizationService
import com.atlassian.jira.application.ApplicationKeys
import com.atlassian.jira.component.ComponentAccessor
def newUserEvent = event as UserCreatedEvent;
def newUser = newUserEvent.getUser();
def newUserEmail = newUser.getEmailAddress();
def joinedApp = "";
def applicationAuthorizationService = ComponentAccessor.getComponent(ApplicationAuthorizationService);
def userManager = ComponentAccessor.userManager;
def user = userManager.getUserByName(newUser.getName());
if (applicationAuthorizationService.canUseApplication(user, ApplicationKeys.SOFTWARE)) {
joinedApp = "JIRA Software";
}else {
joinedApp = "somethingelse";
}
I appreciate for your help in advance.
Thank you!
Jaesang Kim
I found this question when searching for some usage of ApplicationAuthorizationService.
This helped me.
But I think I might be able to help anyone else that has the same issue as the original poster. Here is my guess as to what is happening.
You could try to use one of the Membership related events, but I'm not sure that would work. For one thing, I don't know how you'd detect if the user was just created or not.
I have no idea if this is a dangerously bad practice, but you could try something like
Thread.start{
//all your imports here
Thread.start{
Thread.sleep(3000) //3 seconds
/* the rest of your script here */
}
This starts a new thread, then that thread waits a bit and then executes your code.
The nice thing is the event call itself terminates immediately and the new thread is started asynchronously.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.