Script Runner change multiple user IDs

I have looked at the script runner "Renames A user ID". How do I go about doing a bulk change of user ID's? I have over 400 user IDs that I need to change.

Thanks

1 answer

Here's sample. You need to just execute the script in a loop:

def ren = new com.onresolve.jira.groovy.canned.admin.RenameUser();
def input = [ 
	["admin","newname"],
        ["asd", "usernew"]
        ];
def result = ""
for (e in input) {
	def args = [
                   (com.onresolve.jira.groovy.canned.admin.RenameUser.FIELD_FROM_USER_ID): e[0],
        	   (com.onresolve.jira.groovy.canned.admin.RenameUser.FIELD_TO_USER_ID): e[1],
        	    (com.onresolve.jira.groovy.canned.admin.RenameUser.FIELD_MERGE): false
                ];
        result+=ren.getDescription(args, true)
        //Uncomment to actualy execute, the line above is for preview
        //result+=ren.doScript(args)
        
}
result

Thanks for the response Boris. I have tried your script and also the script from this Scott Dudley from this question below

https://answers.atlassian.com/questions/75640/how-can-i-use-the-groovy-runner-jira-user-id-rename-form-the-command-line

The problem I am having is that both scripts are not updating the app_user table in the database. Which is causing the erorr User 'James.Jones' exists but has no unique key mapping.

In Jira 6x you can update the user ID by editing the user in JIRA. This seems to be updating the column lower_user_name in the app_user table. When I run the scripts this is not updated and the way around it is to run these SQL statement and update the app_user table.

https://confluence.atlassian.com/display/JIRAKB/JIRA+Login+Fails+With+the+Message+-+User+exists+but+has+no+unique+key+mapping

INSERT INTO app_user
SELECT (<id from previous query + 1>,
'username_that_caused_error',
'username_that_caused_error'
FROM app_user;
Not sure if there is an easy way around this since I have 400 users and I am uncertain if
adding additional users on the table app_user will cause any problems in the future.
Any information on this will be greatly appreciated.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

196 views 4 8
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you