We have set up a public screen for users to request a Jira account. It collects their Full Name and Email. I have access to Script Runner. Can someone help me make a script I can kick off during the workflow that will create a user in Jira Internal Directory using the user's email as their Username in Jira? I really need the full script -- I am not strong with ScriptRunner. Thank you in advance so much for any help!!
Here is code I have pieced together. I'm getting an error for the bolded line (line 22) saying, "unable to resolve class UserService.CreateUserRequest"
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.bc.user.UserService
def user = ComponentAccessor.getUserManager().getUserByKey("anyUserKey")
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def userName = customFieldManager.getCustomFieldObject("customfield_10000")
String userNameValue = issue.getCustomFieldValue(userName).toString()
def mail = customFieldManager.getCustomFieldObject("customfield_10001")
String mailValue = issue.getCustomFieldValue(mail).toString()
def pass = ""
def fullName = "FullName"
def userService = ComponentAccessor.getComponent(UserService)
UserService.CreateUserRequest createUserRequest = UserService.CreateUserRequest.
withUserDetails(user, userNameValue, pass, mailValue, fullName)
UserService.CreateUserValidationResult result = userService.validateCreateUser(createUserRequest)
if(result.isValid())
userService.createUser(result)
else
result.getErrorCollection()
Can anyone please help me. This is code I got from others, so it may be totally off!!