Bulk copy custom field values into comments

I have the script runner plugin. I have not found a recent answer to this question that works.

I have a Jira server with a custom field that I want to remove. But before I remove this field I would like to copy the contents of that custom into a comment when the field is not EMPTY.

How can I accomplish this?

Thanks,

Nick

1 answer

1 accepted

0 votes

Hey Nick,

You will have to write a custom script to do so.

Logic would be something like this:

 

- foreach project

 -- foreach issue

  --- get customfield value

   ---- if not null

    ----- create new comment 

To get projects, refer to https://docs.atlassian.com/software/jira/docs/api/7.0.8/com/atlassian/jira/project/ProjectManager.html

To get custom field and values, refer to https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/issue/CustomFieldManager.html

To create comment, refer to https://docs.atlassian.com/software/jira/docs/api/7.0.5/com/atlassian/jira/issue/comments/CommentManager.html

 

Hope that helps.

Cheers

Bhushan

Bhushan,

I've started working on implementing the pseudo code you have above. Here is what I have so far:

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.ProjectManager

def projectMan = ComponentAccessor.getProjectManager();

String results = "";

List projectList = projectMan.getProjects();

for(Project p : projectList)
{
results = p.getName() + " ";
}

return results

I am getting an error at line 11 that the class Project is resolvable. Is there something else I need to import to be able to work with objects of type Project?

 

Edit: Nevermind, I needed to import com.atlassian.jira.project.Project

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 ...

2,815 views 11 18
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