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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,314 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot