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

How to copy issues after due date is passed to another project with groovy

Hey i need you help please.

I would like to copy issues from a project to another after due date is passed. 

I will put in place a job every 24 hours.

I work on jira 9.4.1 and scriptrunner 8.3.0.

I found other topics, i tried to build something but it's failed.

Anyone can help me please? 

3 answers

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 31, 2023

Hi @Suketa

From what you have described in your description, you are trying to copy over an issue from one project to another project after a certain time period.

There is already an example of how to copy the issue from one project to another project available in the Adaptavist Library.

Regarding the date when you want the script to execute, you could set something like an Escalation Service or a Custom Job to trigger the copying process.

I hope this helps to solve your question. :-)

Thank you and Kind regards,

Ram

It's ok for me.

I had to change def issueToCopy = issueManager.getIssueObject(issueKey)

by def issueToCopy = issueManager.getIssueObject(issueKey.getKey())

Thank you 

I have tried something like this but an error occured. "IssueKey" can not be apply like this in method...

import com.onresolve.scriptrunner.runner.ScriptRunnerImpl

import com.onresolve.scriptrunner.canned.jira.utils.ConditionUtils

import com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CloneIssue

import com.atlassian.jira.component.ComponentAccessor

 

def projectkey = "AAAA"

 

Issues.search('project = BBBBB AND duedate > startOfDay()').each {issueKey ->

 

    // do something

   

def projectManager = ComponentAccessor.projectManager

def issueManager = ComponentAccessor.issueManager

 

def projectToCopy = projectManager.getProjectByCurrentKey(projectkey)

def issueToCopy = issueManager.getIssueObject(issueKey)

 

def blockIntraprojectLinks = '{l -> l.sourceObject.projectObject != l.destinationObject.projectObject}'

 

//Set the creation parameters/inputs (use clone issue but with no link type)

def inputs = [

    (CloneIssue.FIELD_TARGET_PROJECT)       : projectToCopy.key,

    (CloneIssue.FIELD_LINK_TYPE)            : null,

    (ConditionUtils.FIELD_ADDITIONAL_SCRIPT): [

        "checkLink = $blockIntraprojectLinks;",

        ""

    ],

    (CloneIssue.FIELD_SELECTED_FIELDS)      : null, //clone all the fields

    (CloneIssue.SKIP_EPIC_LINKS)            : "true",

] as Map<String, Object>

def executionContext = [issue: issueToCopy] as Map<String, Object>

 

def newClonedIssue = ScriptRunnerImpl.scriptRunner.createBean(CloneIssue)

// Execute the clone action with the specified inputs

def updatedExecutionContext = newClonedIssue.execute(inputs, executionContext)

//The issue has been successfully cloned

assert updatedExecutionContext.newIssue

 

}

 

Suggest an answer

Log in or Sign up to answer