It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Dear All, 

I have the following question: one of our user working for years in JIRA. Now he's got a new AD user, wich means new JIRA user. But the problem is, that of course every object (worklogs, assigned tickets, filters, permissions, roles ect) remains at his older user.

Do you know any addon, script, anything, that we can user, to 'change' his old user objects ownership to the new user?

I know, scriptrunner has a part, that can change the ownership of filters and dashboards. That' a good start, but absolutely not enough. Changing every role, permission, assigne would take weeks (although, we would be never sure, if it's fully completed), also the worklogs owner cannot be changed this way.

 

I'm hoping for any kinf of help :)

 

Best: Peter

1 answer

1 accepted

0 votes
Answer accepted
tom lister Community Leader Jan 09, 2020

Hi @Peter Cselotei 

If your confident with SQL and the Jira database you could try some of the tricks in this article.

https://community.atlassian.com/t5/Migrations-articles/Jira-LDAP-Migration-using-SQL/ba-p/942752

Tom

Hi @tom lister  and thanks for answering.

Unfortunately I have no access to the database (security reasons), also I hardly think that any further answer will come, so I accept this answer, and still hope, some script or addon may come up in the future.

 

Thanks!

Best: Peter

tom lister Community Leader Jan 22, 2020

Hi @Peter Cselotei 

I’ll see if I have any useful groovy scripts.

Tom

Hi @Peter Cselotei 

FYI

we have this script as a start point for updating comments. When I ran it didn't update but I can't see why from the API notes.

It needs ScriptRunner installed for the JQL query function

 


import com.atlassian.jira.issue.comments.MutableComment
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager

import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Logger
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager

def log = Logger.getLogger("com.cheil.logging")

// **********************************************

// **********************************************
String oldUser = "old@domain.com"
String newUser = "new@domain.com"
def jqlSearch = 'issueFunction in commented("by ' + oldUser + '")'
List<Issue> issues = null
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def userUtil = ComponentAccessor.getUserUtil()
def commentMgr = ComponentAccessor.commentManager
UserManager userMgr = ComponentAccessor.getUserManager()
ApplicationUser newAppUser = userMgr.getUserByName(newUser)
List<Comment> comments
MutableComment mut
IssueManager issueManager = ComponentAccessor.getIssueManager()

SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)
if (parseResult.isValid()) {
// searchService.search()
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())

searchResult.getResults().each { issue ->
def issueData = issueManager.getIssueObject(issue.id)
log.info (issueData.key)
comments= commentMgr.getCommentsForUser(issueData, user)
comments.each {comment ->
if (commentMgr.isUserCommentAuthor(user, comment)) {
log.info("author: " + comment.getAuthorApplicationUser())
mut=commentMgr.getMutableComment(comment.getId())

mut.setAuthor(newAppUser)
try {
commentMgr.update(mut, true)
} catch (Exception e)
{
log.info(e.getMessage())
}
log.info("newAuthor: " + mut.getAuthorApplicationUser())
}
}
}
// issues = searchResult.issues.collect {issueManager.getIssueObject(it.id)}
} else {
log.error("Invalid JQL: " + jqlSearch);
}

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you