I'm trying to trigger an event when new user accounts are added, and am having trouble accessing the UserEvent in the listener.
I'm listening for "AutoUserCreatedEvent", "UserAuthenticatedEvent", "UserCreatedEvent", "UserEvent".
Here is a snippet of code where the error occurs. I think the problem is that I am defining a new UserEvent, how do I access the user that is being referenced in the trigger that happened in the first place?
Code
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.AbstractEvent
import com.atlassian.jira.event.user.UserEvent
def newUserEvent = UserEvent;
def appUser = newUserEvent.getUser(); // This errors (shown below)
int userEventType = newUserEvent.getEventType(); // This errors too (not shown, same idea though)
Error
I think the key piece here is this "applicable for argument types: () values: []".
2018-06-27 17:08:11,907 https-jsse-nio-8443-exec-5 ERROR anonymous 1028x672557x1 - xxx.xxx.xxx.xxx /rest/api/2/search/ [c.o.scriptrunner.runner.AbstractScriptListener] Script function failed on event: com.atlassian.crowd.event.user.UserAuthenticatedEvent, file: <inline script>
groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.event.user.UserEvent.getUser() is applicable for argument types: () values: []
Possible solutions: getUser(), getTime(), getAt(java.lang.String), use([Ljava.lang.Object;), use(java.lang.Class, groovy.lang.Closure), use(java.util.List, groovy.lang.Closure)
at Script90.run(Script90.groovy:11)