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

ScriptRunner Change status on a issue based on condition

Hello everyone. We have a number of issues with a given status. I would like to change their status when they have been inactive for a given period of time.

Is it possible to create a script in scriptrunner that can do exactly this?

1 answer

1 accepted

1 vote
Answer accepted
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 10, 2023

Hi @Søren Hansen 

Yes this would be possible to be created in Scriptunner under "Job". I mean this script should run e.g. everyday at midnight and gather all issues which satisfy your conditions.

How would the script look like. I need some ideas.

I have something like this, it looks if the issue is more than 6 months inactive:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.search.SearchResults
import com.atlassian.jira.web.bean.PagerFilter
import org.joda.time.DateTime

// Get the Jira Service Desk instance
def jira = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()

// Get the project key
def projectKey = "MY_PROJECT_KEY"

// Get all issues in the project that have a status different than resolved
def searchResults = ComponentAccessor.searchProvider.search("project = '" + projectKey + "' and status != 'Resolved'", jira, PagerFilter.getUnlimitedFilter())

// Get all the issues
def issues = searchResults.getIssues()

// Define date 6 months ago
def sixMonthsAgo = new DateTime().minusMonths(6)

// Iterate through all issues and change status if inactive for 6 months
for (Issue issue : issues) {
def lastComment = issue.getComments().last()
if (!lastComment || lastComment.getCreated().toDate() < sixMonthsAgo.toDate()) {
issue.setStatus("Resolved")
}
}

Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 11, 2023
Like # people like this
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 11, 2023

I agree with what @Fabio Racobaldo _Herzum_ told you.

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events