Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,459,375
Community Members
 
Community Events
176
Community Groups

how copy some issues from a project to other projects by groovy or scriptrunner

i want to copy some issues to some different projects, i want know some method about this

1 answer

0 votes

Hi @ZhangXiaoyu ,

welcome to the Atlassian community!

Please, could you specify your use case? Do you need to clone issues as part of transition in a workflow or based on an issue event?

Btw, here a useful starting point for your request https://scriptrunner.adaptavist.com/5.6.8/jira/recipes/workflow/servicedesk/clone-issue-sd.html

Hope this helps,

Fabio

clone issues as part of transition in a workflow,
I would like to clone an issue from one project into several different projects without changing the issueType  

here an useful code :

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.type.EventDispatchOption;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueFactory;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.user.ApplicationUser;

IssueFactory issueFactory = ComponentAccessor.getIssueFactory();
IssueManager issueManager = ComponentAccessor.getIssueManager();
ProjectManager projectManager = ComponentAccessor.getProjectManager();
ApplicationUser currentUserObj = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();

Project destinationProject = projectManager.getProjectByCurrentKey("YOUR DESTINATION PROJECT KEY HERE");

MutableIssue newissue = issueFactory.getIssue();
newissue.setSummary (issue.getSummary());
newissue.setProjectObject(destinationProject);
newissue.setIssueTypeId(issue.getIssueTypeId());
newissue.setDescription(issue.getDescription());
newissue.setReporter(issue.getReporter());
newissue.setAssignee(issue.getAssignee());
//OTHER FIELDS HERE
issueManager.updateIssue(currentUserObj, newissue, EventDispatchOption.DO_NOT_DISPATCH, false);

 

Please, try it!

Hi Fabio, is this code works to clone issue in multiple projects?

Hi @prasad biddika ,

yes, it does. Please make sure tu set the correct project as desinationProject ;)

Suggest an answer

Log in or Sign up to answer