Hello,
We would like to replace an old custom field with a new one.
For all existing issues, I have to copy the old custom field values in the new one, but the problem is that they do not have the same values.
I do have en excel file with the mapping table between old and new custom field values.
I have more than 60000 issues to edit, so I can not do it manually with "Bulk Edit".
Please do you have any idea on the script that will allow me to do that ?
The script must read the mapping table (csv) and map custom field A value with the corresponding value for custom field B.
Thank you so much for your help !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure - here is some more information if you are not familiar with automation:
There are two types of automation:
Automation Basics: https://www.atlassian.com/software/jira/guides/expand-jira/automation
You can do this via global rules to apply to all projects also. You'll need to be a Jira Admin/Site Admin, go to Jira Settings > System > Automation Rules (left-hand menu).
For more on using Automation For Jira see these help pages.
Jira Automation Template Library to help get you started quickly:
https://www.atlassian.com/software/jira/automation-template-library#/labels/all/customLabelId/1453
Then you would create a Scheduled trigger. Have it run once a day.
Then at a JQL to the trigger to get all of the issues you want to update. I would just done one issue first to test it. Something like KEY=ABC-123
Then add an action to Edit the issue
Select the new field you want to add the value into
Then choose Copy from from the 3 dots menu on the right
Put in the field you want to copy from.
Then save and publish the rule. Make sure it is active.
Click the button for Run Rule. That will run it right now and you should see the result.
If all is good, then go back and update your JQL to include all of the issues.
Save and publish again. Then click Run Rule again.
Once all are done, but sure to make the rule inactive so it won't run every day.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aimane SBAI
Take a look at his script here to get started with the updating custom field part.
The code below will help you in parsing csv.
/*
CSV Format
userName,userEmail,userName
user1,user1@example.com,"User 1 Name"
user2,user2@example.com, "User 2 Name"
user3,user3@example.com, "User 3 Name"
CSV parsing code copied from: https://stackoverflow.com/questions/49675423/read-csv-file-and-put-result-in-a-map-using-groovy-without-using-any-external-l
*/
File file = new File("/opt/jira/home/scripts/file.csv")
def csvMapList = []
file.eachLine { line ->
def columns = line.split(",")
def tmpMap = [:]
tmpMap.putAt("userName", columns[0])
tmpMap.putAt("userEmail", columns[1])
tmpMap.putAt("userFullName", columns[2])
csvMapList.add(tmpMap)
}
// csvMapList.getAt("userName") //return all usernames
// return csvMapList.getAt("userEmail") //return all emails
//csvMapList.getAt("userFullName") //return all usernames
return csvMapList
I hope it gives you a good start.
Share you code here if you need further help.
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have also made video on parsing JQL and performing bulk operations along with the code that you can find with explaination.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ravi Sagar _Sparxsys_ Thanks a lot for your answer !
In your script, I do not see where do we pick values in the csv file, to put them in the destination custom field.
Here is what I would like this script to achieve :
1. Load csv file values (Column 1 = CustomField A values / Column 2 = CustomField B values)
2. Check issue's CustomField A value, and put the corresponding value in CustomField B.
Thank you so much for your help !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you have the Automation for Jira feature available in your environment? If so, you would write a manually triggered rule to copy the values.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jira Product Discovery Premium is now available! Get more visibility, control, and support to build products at scale.
Learn moreOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.