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