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,359,986
Community Members
 
Community Events
168
Community Groups

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 Software

An update on Jira Software customer feedback – June 2022

Hello Atlassian Community! Feedback from customers like you has helped us shape and improve Jira Software. As Head of Product, Jira Software, I wanted to take this opportunity to share an update on...

4,986 views 18 31
Read article

Atlassian Community Events