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

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

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

405 views 13 14
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