Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

can i update user email using script?

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 11, 2015

Is it possible to update user email using script?

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

4 votes
Bartosz Czyżewski March 30, 2017

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)
1 vote
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 11, 2015

You can do it with UserManager:

UserManager userManager = ComponentAccessor.getUserManager()
userManager.updateUser(appUser);

Please see javadoc.

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 12, 2015

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 ?

Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 12, 2015
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 12, 2015
srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 12, 2015

Is indexing required if we update the email using the above method?

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 12, 2015

I have used usertemplate and it worked {code} UserTemplate userTemplate = new UserTemplate(user); userTemplate.setEmailAddress("abc@abc.com"); userManager.updateUser(userTemplate); {code}

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 12, 2015

Will it cause performance issues and trigger indexing if we update email address for hundreds of users?

Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 12, 2015

I guess there should not be performance problems but you never know before you try :-)

Bartosz Czyżewski March 29, 2017

@Volodymyr Krupach did you managed to write simple script with ApplicationUserBuilder?

Could you please provide us with a sample? smile

Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2017

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.

1 vote
GabrielleJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 11, 2015

Yes, you can do it via curl against the JIRA REST API.

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 11, 2015

Can we do it using groovy? we need to update email ids for many users.

GabrielleJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 12, 2015

Yes you can too! Sorry if I'm biased to shell :)

0 votes
srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 11, 2015

Hi Atlassians, any update please?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events