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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get Release Date and Clear due date if the Fix version is set to Empty via Script runner

Hi ,

 

I would like to get the Release date from the Fix version and Clear the due date if the Fix version is setup to Empty. I'm not good in scripting, can someone help on this?

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueManager
import java.util.ArrayList;
import java.util.Collection;


Collection<Version> fixVersions = new ArrayList<Version>();
IssueManager issueManager = ComponentAccessor.getComponent(IssueManager.class)
def customFieldManager = ComponentAccessor.getCustomFieldManager()

 

//Custom field for Due date
def cDuedate = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12111")
def cDuedateValue = event.issue.getCustomFieldValue(cDuedate)

def issue = (MutableIssue)event.issue
def version = (Version)issue.getFixVersions().first()
def setDate = version.getReleaseDate() as Date

def issueVersions = event.issue.getFixVersions()
def fixVersion= issue.getFixVersions()
log.warn "Release Date = ${setDate}"

//if (fixVersion.empty) {
if (issue.fixVersions*.name.contains("None")){
issue.setCustomFieldValue (cDuedate,null)
issueManager.updateIssue(event.getUser(), issue , EventDispatchOption.ISSUE_UPDATED, false)

} else {
issue.setCustomFieldValue (cDuedate,setDate)
issueManager.updateIssue(event.getUser(), issue , EventDispatchOption.ISSUE_UPDATED, false)
}

1 comment

Hi @Rodolfo So 

Did you see this similar community posting and answer on this topic:

How to use ScriptRunner to update Issue Due Date based on fixVersion release Date

https://community.atlassian.com/t5/Jira-questions/How-to-use-ScriptRunner-to-update-Issue-Due-Date-based-on/qaq-p/1212254

Best regards,

Bill

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

1,241 views 18 23
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you