Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Bulk copy field value to another but not same values

Aimane SBAI
Contributor
October 8, 2021

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 !

 

 

3 answers

1 vote
John Funk
Community Champion
October 8, 2021

Hi @Aimane SBAI 

I do this through a Scheduled trigger Automation rule. 

Aimane SBAI
Contributor
October 11, 2021

Hi @John Funk ,

Thanks for your answer. 

Can you give me more details please ?

John Funk
Community Champion
October 12, 2021

Sure - here is some more information if you are not familiar with automation:

There are two types of automation:

  • Global: In the Free version, you get 100 executions per product, per month
  • Project: In all versions, you get unlimited executions per month

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. 

Like • Sari Kachorovsky likes this
0 votes
Ravi Sagar _Sparxsys_
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.
October 8, 2021

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 

Ravi Sagar _Sparxsys_
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.
October 8, 2021

I have also made video on parsing JQL and performing bulk operations along with the code that you can find with explaination.

Like • Aimane SBAI likes this
Aimane SBAI
Contributor
October 12, 2021

@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 !

0 votes
Trudy Claspill
Community Champion
October 8, 2021

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.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
atlassian, jira product discovery, jpd premium, product management, idea management, product discovery, jira premium, product planning, atlassian community, product development, roadmap planning, product prioritization, feature management

Introducing Jira Product Discovery Premium ✨

Jira Product Discovery Premium is now available! Get more visibility, control, and support to build products at scale.

Learn more
AUG Leaders

Atlassian Community Events