Is it possible to update user email using script?
Community moderators have prevented the ability to post new answers.
No problem. Got one for you:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.bc.user.ApplicationUserBuilderImpl import com.atlassian.jira.user.ApplicationUser def um = ComponentAccessor.getUserManager() def user = um.getUserByName('username') as ApplicationUser def newData = new ApplicationUserBuilderImpl(user).name('newUserName').build() um.updateUser(newData)
You can do it with UserManager:
UserManager userManager = ComponentAccessor.getUserManager() userManager.updateUser(appUser);
Please see javadoc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Volodymyr, Thanks for the update. I did not see any setEmail() method. Could you please tell how to set email to existing appUser object ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need to use ApplicationUserBuilder: https://docs.atlassian.com/jira/latest/com/atlassian/jira/bc/user/ApplicationUserBuilder.html#emailAddress-java.lang.String-
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ApplicationUserBuilderImpl has constructor that accepts ApplicationUser: https://docs.atlassian.com/jira/latest/com/atlassian/jira/bc/user/ApplicationUserBuilderImpl.html#ApplicationUserBuilderImpl-com.atlassian.jira.user.ApplicationUser-
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is indexing required if we update the email using the above method?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have used usertemplate and it worked {code} UserTemplate userTemplate = new UserTemplate(user); userTemplate.setEmailAddress("abc@abc.com"); userManager.updateUser(userTemplate); {code}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Will it cause performance issues and trigger indexing if we update email address for hundreds of users?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I guess there should not be performance problems but you never know before you try :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Volodymyr Krupach did you managed to write simple script with ApplicationUserBuilder?
Could you please provide us with a sample?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do not have a script for user editing but as always JIRA sources is your best friend. Please check com.atlassian.jira.web.action.admin.user.EditUser class.
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.
Can we do it using groovy? we need to update email ids for many users.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes you can too! Sorry if I'm biased to shell :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Atlassians, any update please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.